Hi,
I am using C# in .NET 2.0 and im trying to read a stream from a socket. The code works on the first attempt but fails on subsequent attempts. It is in a multithreaded application. It seems the PlayerStream.Read() sets the PlayerSocket.Connected=false???
I am getting the following error:System.IO.IOException: Unable to read data from the transport connection: 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. ---> System.Net.Sockets.SocketException: 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 at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at GameServer.PlayerHandler.Process() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\RPNServer2\LobbyServer\GameServer\serverData.cs:line 394
The code i am using to set up the thread and socket is as follows
//Code that listens for and accepts connection, if handler!=null it then passes a reference through to the class that runs the threadTcpClient
PlayerStream = PlayerSocket.GetStream();
PlayerStream.ReadTimeout = 250;
bytes =
The code i am using to try and read the stream is as follows:
PlayerSocket.Client.Blocking =
else
I have been attempting to fix this myself for the past few days but have had no luck, maybe one of you guys will have some idea.
Rgds,
Chris