unbind socket connection C#/python -


what have:

  • i have 2 socket client programs written in c#.
  • i have 1 socket server program (not written me works) in python.

the problem:

the first c# socket client wrote works fine , can communicate python server client. can send data on no issue. wanted rewrite code make more object oriented, made second program same first in terms of done.

the issue second 1 won't connect, saying this:

system.net.sockets.socketexception: attempt made access socket in forbidden way access permissions.

i googled , have come realization connection first connection hasn't been unbound.

when did netstat -a, saw connection , said time_wait @ end.

the question is, how unbind it? on c#/client side?

fyi have tried closing/disconnecting/shutting down socket , none of worked. put in command

connection.setsocketoption(socketoptionlevel.socket, socketoptionname.reuseaddress, true); 

upon instantiation of socket connection did not work either.

would have on server side unbind connection?

i know said calling close or disconnect.

but reinitializing socket variable.

eg: connection = new system.net.sockets.socket(...

if using older version of .net may have call dispose() after call close().

eg:

connection.close(); connection.dispose(); connection = new system.net.sockets.socket(... 

be sure work sockets within try statements calls send , receive data or close socket result error @ stage, should log error , call close() , if applicable dispose() on socket instance clear resources. once has been done, can reinitialize new instance of socket attempt new connection server.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -