Small update. I haven't solved the problem of lingering sockets. However
a bit of re-architecturing means that I now reuse sockets rather than
creating new ones. I now have one socket per server/port and use the
send and recieve functions on that socket.
The simplified code below shows this in action:
IPAddress ipa = IPAddress.Parse ("192.168.0.10" );
IPEndPoint ipe = new IPEndPoint(ipa, 80);
Socket s = new Socket(AddressF amily.InterNetw ork, SocketType.Stre am,
ProtocolType.Tc p);
s.SetSocketOpti on(SocketOption Level.Socket,
SocketOptionNam e.ReceiveTimeou t, 30000); s.Connect(ipe);
writeToSocket(s , ipe, "1");
writeToSocket(s , ipe, "2");
writeToSocket(s , ipe, "3");
s.Shutdown(Sock etShutdown.Both );
s.Close();
Where writeToSocket contains my code for sending the data down the
socket and waiting for a response.
If anyone does solve the lingering socket problem then let me know.
Cheers
James.
Jimbo wrote:
Unfortunately no. My client is calling web services on various different
servers.
rawCoder wrote:
Just a hunch.
If your scenario permits, Have you tried closing the connection from
server?
"Jimbo" <ji***@notexist .domain.com> wrote in message
news:d2******** **@titan.btinte rnet.com...
Hi Guys,
I'm sorry if you have heard this one before but searching the net
hasn't found a solution.
I am using Socket in a client to connect to a server. However, after
I've finished sending and recieving data and call the Close() method the
socket lingers for a couple of minutes. This is demonstrated by using
netstat -a.