Can a socket be reused after calling Shutdown?

  • Thread starter Thread starter Alain Dekker
  • Start date Start date
A

Alain Dekker

In circumstances where the Socket.Disconnect method is not available (.NET
1.1 or the Compact Framework 2.0), is it possible to re-used the socket
after calling Shutdown?

If not, is there a PInvoke that can be used to call a lower-level API to
achieve reuse?

My application requires a connection to be made, data sent and then the
connection terminated. The target application is legacy (and cannot be
changed) and simple listens on a single port number for incoming
connections.

Thanks,
Alain
 
The current code calls Shutdown on the socket, then closes it. The next time
a message must be resent, the socket is re-created. I can continue to use
that method. You're right on the larger issue that if the .NET version
doesn't support some features it might be time to move onto a more recent
version. But as anyone who works on a limited time and fiscal budget will
know, upgrading is risky and costly.

Thanks,
Alain
 
Back
Top