Socket Problem

N

Nick Zdunic

Ok - something for socket jockeys


I have a .NET application using the TcpClient class from System.Net.Sockets


I use this to connect to an IP address/Socket on the other side of Australia.

There is a problem though. The read from the socket returns 0 bytes which means the socket/host has closed down.


However using a telnet session, I know that this isn't the case. The telnet session sends data through Ok.


So what could be causing the problem:


Firewalls

Routers

Or something else

Note that the client can read fine from a host application located on my machine.
 
J

Jon Skeet [C# MVP]

Nick Zdunic said:
Ok - something for socket jockeys

I have a .NET application using the TcpClient class from
System.Net.Sockets

I use this to connect to an IP address/Socket on the other side of
Australia.

There is a problem though. The read from the socket returns 0 bytes
which means the socket/host has closed down.

However using a telnet session, I know that this isn't the case. The
telnet session sends data through Ok.

That doesn't mean that the socket hasn't been closed by the other side
though.
So what could be causing the problem:

I suggest you use a network monitor to find out what's going on. Do you
have control of the server app as well? If so, add some debug
information to see when it's closing the socket and why.
 
N

Nick Zdunic

Fixed the problem. The host I was connecting was not actually a host in the
strict sense - it was another client. I had two TcpClients connecting to
it - one which was sending messages and another that was reading. I have
modified the program to use the one connection for both sending and
receiving.
 

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