views:

167

answers:

3

Using c# I am trying to send messages to a server. However I am getting the socket exception 10060 which means a connection time-out error. What could be the problem?

A: 

Could be that the server's not listening on the specified port or it's not accepting the connection. This could be because of a firewall (software or hardware).

I would test the connection to the server with a third-party app. For instance, just telnet to the host on the given port (if it's a TCP connection) and see if a connection is established.

On the server, you can run netstat -na (on windows) to see if there's anything listening on the destination port.

Ryan Emerle
I removed the firewall and now am getting a socket exception saying the connection was refused.Whats going on?
Avik
+1  A: 

Check that application on your server is up and running. Double check address and port. Check that your firewall allows connections of the type you are trying to make.

The simplest way would be probably to use telnet and see if you can connect.

Konstantin Spirin
A: 

Go to the machine and use telnet locally:

telnet localhost yourportnumberhere

...if you don't get a connection, forget about firewalls - you're just not listening on that port.

If it works, work your way back from the machine to one on it's network and try again. If that fails, it's the firewall on the machine that is blocking it.

If that works, then use the same telnet command on your machine (or at least the one running the code that is trying to connect)

Neil Trodden