Problem while connecting to a remote computer using TcpClient.Connect()

Hi there,

When I try to connect to a remote computer using TcpClient.Connect(), I receive a SocketException with the following error:

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.

It works fine when I use it in a LAN or try to connect to the same computer. But when I try to connect to another computer on the Internet, this exception is thrown.

Any advice?!

[511 byte] By [Moshfegh] at [2008-2-22]
# 1
This is due to the fact that the connection attempt is timing out
Please make sure that the IPAddress/Hostname is correct
DurgaprasadGorti at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...
# 2

Are you inside a domain? Do you use proxy to handle requests going outside.. try doing a telnet and see if that succeeds..

Malar at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...
# 3
Simple ping should also help. Rule of thumb is if you can ping a particular IP then System.Net should be able to connect to it
mahjayar at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...
# 4

Note:Ping uses ICMP whereas sockets use Tcp or UDP. Though, this might help in most cases, there can be cases where this rule doesnt work

Malar at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Networking and Communication...

.NET Development

Site Classified