socket.close()

  • Thread starter Thread starter Ronny
  • Start date Start date
R

Ronny

I need to close a socket and use it immedeiatly again with another local
port. Is it enough to do socket.close() in order to release all resources,
or must I do anything more(like a delete or similar) before I use the "new"
operator?
Regards
Ronny
 
Ronny said:
I need to close a socket and use it immedeiatly again with another local
port.

You can't.
Is it enough to do socket.close() in order to release all resources,

Yes, Close() is equivalent to Dispose(). But after you close the
socket, it can't be reused. You have to create a new instance.

If the socket is a connection-oriented socket (e.g. TCP), also make sure
you do a graceful shutdown when possible (i.e. there haven't been any
errors on the socket).

Pete
 
Back
Top