T
TDC
I've got an HttpHandler that creates a TcpClient, connects to a server
to exchange some data, and then disconnects.
The problem is I am eventually getting SocketExceptions [Only one
usage of each socket address (protocol/network address/port)is
normally permitted].
After doing some research, I've discovered that I was exhausting the
default range of local ports being dished out to the TcpClient
objects, and instead I implemented assigning the Local Endpoint
manually so I could increment the local port number myself.
As the Local Address, Remote Address, and Remote Port are all fixed,
the local port is the field I have to work with to create unique
connections.
The solution drastically improved the success rate, but I'm still
occasionally getting address-in-use errors. As long as my previous
usage of the local port has gone through its TIME_WAIT period, I
should be able to use that port number again, AFAIK.
Has anyone hit this issue before? Any hinst as to why the
SocketExceptions still persist is appreciated!
to exchange some data, and then disconnects.
The problem is I am eventually getting SocketExceptions [Only one
usage of each socket address (protocol/network address/port)is
normally permitted].
After doing some research, I've discovered that I was exhausting the
default range of local ports being dished out to the TcpClient
objects, and instead I implemented assigning the Local Endpoint
manually so I could increment the local port number myself.
As the Local Address, Remote Address, and Remote Port are all fixed,
the local port is the field I have to work with to create unique
connections.
The solution drastically improved the success rate, but I'm still
occasionally getting address-in-use errors. As long as my previous
usage of the local port has gone through its TIME_WAIT period, I
should be able to use that port number again, AFAIK.
Has anyone hit this issue before? Any hinst as to why the
SocketExceptions still persist is appreciated!