TcpClient SockException - Can't Connect
-
I have a customer that is getting the following exception when the program attempts to make a simple connection: Exception: System.Net.Sockets.SocketException Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Source: System at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) This seems to me that the server isn't running anything on the specified port, however he swears he can telnet to the port on the command prompt. Here is the exact code that causes this problem.
System.Net.Sockets.TcpClient testConnection = new System.Net.Sockets.TcpClient (); testConnection.Connect (smtpHost, smptPort); testConnection.Close();
I believe he has entered his information incorrectly but he says it has just recently started happening and it worked before without any problems. Could XP SP2 be causing this problem? There is enhanced code that only allows a certain number of connections to be made but I thought it gave a policy violation error instead of the timeout error. Has anyone experienced anything like this before? Thanks. - Andrew T Finnell -
I have a customer that is getting the following exception when the program attempts to make a simple connection: Exception: System.Net.Sockets.SocketException Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Source: System at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) This seems to me that the server isn't running anything on the specified port, however he swears he can telnet to the port on the command prompt. Here is the exact code that causes this problem.
System.Net.Sockets.TcpClient testConnection = new System.Net.Sockets.TcpClient (); testConnection.Connect (smtpHost, smptPort); testConnection.Close();
I believe he has entered his information incorrectly but he says it has just recently started happening and it worked before without any problems. Could XP SP2 be causing this problem? There is enhanced code that only allows a certain number of connections to be made but I thought it gave a policy violation error instead of the timeout error. Has anyone experienced anything like this before? Thanks. - Andrew T FinnellYou should make sure the client - as well as your development team - is updated to the newest .NET Framework Service Packs, available at http://msdn.microsoft.com/netframework/downloads/[^]. Be sure to download the right versions and locales, as well as for the right platform (Windows Server 2003 uses a different installer technology than the rest of the current Windows platforms). For changes made in Windows XP SP2 that affect developers, read http://support.microsoft.com/default.aspx?pr=WindowsXPsp2Dev[^]. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]