467,877 Members | 1,202 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

Network stream error "Unable to read data from the transport connection."

Hello,

I'm trying to make a simple socket application, something like a chat
application, but when I run it, it shows the following error when the client
connects to the server: "Unable to read data from the transport
connection.". I'm posting the code, so if somebody can help I'll be very
grateful.

private void DoListen()
{
try
{
Server.Start();
Client = Server.AcceptTcpClient();
state = SocketState.Connected;
stream = Client.GetStream();
stream.BeginRead(dataBytes,0,dataBytes.Length, new
AsyncCallback(ReadStream),null);
}
catch
{
state = SocketState.Closed;
}
}

private void ReadStream (IAsyncResult args)
{
if (state == SocketState.Connected)
{
int I;
I = stream.EndRead(args); // The error happens here!!!
if (I > 0)
{
data = Encoding.ASCII.GetString(dataBytes);
stream.BeginRead(dataBytes,0,dataBytes.Length, new
AsyncCallback(ReadStream),null);
}
}
}

Thanks
Nov 15 '05 #1
  • viewed: 2937
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Loane Sharp | last post: by
1 post views Thread by mulham.haffar | last post: by
3 posts views Thread by carmelo8 | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.