WinSock Error (Error code: 10054)

S

SK

Hi all,

I am dealing with sockets in my code.

I open them like -
System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse
(szIPSelected);
System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint
(remoteIPAddress, alPort);
// Connect to the remote End point in the socket.
m_socClient.Connect(remoteEndPoint);

After having done my work I close it by-
m_socClient.Shutdown(SocketShutdown.Both);
m_socClient.Close();

I get an error "An existing connection was forcibly closed by the remote host
Error code: 10054" after running the application several times.
Am I missing on something?

Best regards,
SK
 
I

Ivar

This is normal error, what you must skip or handle.

This happens when computer you are connected to closes connection(without
ShutDown).
 
S

SK

So does that mean that I am bound to get such errors when opening/closing
sockets many times.
So is simply ignoring these error messages fine?
I was thinking that I made some mistake in closing the sockets.

Best regards,
SK
 
I

Ivar

So is simply ignoring these error messages fine?
Usually yes, but it depends if you want notify your app that remote computer
closed connection.
I was thinking that I made some mistake in closing the sockets.
I'm sure that your destination machine(server) causes this. If you send
Shutdown() then server won't
close connection as expected, it just closes it (No shutdown).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top