Unable to allocate new socket except for the exception of arguments

I created a new project and the only line of code is to allocate a new socket:

Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

      

And it throws an exception:

An unhandled exception of type system.net.sockets.socket exception occurred in System32.DLL

Additional information: An invalid argument was specified

He also writes these codes: 0x80004005, ErrorCode: 10022

+3


source to share


1 answer


Hopefully my late answer is still helpful for others who have the same problem.

I had the same problems with several network / socket examples, and each search (mismatching parameter combinations? / Disconnect instead of Close / optional settings for address or socket reuse) did NOT fix it. This "Invalid Argument" error message is misleading. Now I figured it out:

Chances are you also run the code in Visual Studio or Executable (exe) directly on the network volume or share. Even executed as an administrator does not work.



When I copied the project executable / code to a local volume on my PC, all socket programs worked fine (even without admin rights).

Changing your User Account Control (UAC) rights or your company's domain policies might work around this issue.

FJ relationship

+7


source







All Articles