Why do i get This Error ??????
-
i have a server and client networked application , each time i test them , gives me an error "Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request. " Here is the code for the client , knowing that the server doesn't disconnect the current client , the server still see the client as connected the client code as follows :
void RunClient() { try { IPAddress ip = IPAddress.Parse("127.0.0.1"); int port = 5079; IPEndPoint ipendpoint = new IPEndPoint(ip, 5079); //create the tcp client client = new TcpClient(); client.Connect(ipendpoint); Console.WriteLine("The Client has been Connected Successfully"); //begin Reading lock (client.GetStream()) { (client.GetStream()).BeginRead(data, 0, data.Length, new AsyncCallback(IASyncResultCallBack), client); } } catch (Exception s) { this.Invoke(new SetText(SetTextMethod), new object[] { s.Message }); } } void IASyncResultCallBack(IAsyncResult ar) { try { //get the tcp client instance TcpClient currentclient = ar.AsyncState as TcpClient; if (currentclient != null) { if (currentclient.GetStream().CanRead) { //get the instance of the data int count = (currentclient.GetStream()).EndRead(ar); if (count <= 0) { //disconnect the current client currentclient.Close(); currentclient = null; GC.Collect(); return; } //build the Received Text ReadText(data, 0, data.Length); } } //now begin Reading again lock (currentclient.GetStream()) { currentclient.GetStream().BeginRead(data, 0, data.Length, new AsyncCallback(IASyncResultCallBack), currentclient);
-
i have a server and client networked application , each time i test them , gives me an error "Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request. " Here is the code for the client , knowing that the server doesn't disconnect the current client , the server still see the client as connected the client code as follows :
void RunClient() { try { IPAddress ip = IPAddress.Parse("127.0.0.1"); int port = 5079; IPEndPoint ipendpoint = new IPEndPoint(ip, 5079); //create the tcp client client = new TcpClient(); client.Connect(ipendpoint); Console.WriteLine("The Client has been Connected Successfully"); //begin Reading lock (client.GetStream()) { (client.GetStream()).BeginRead(data, 0, data.Length, new AsyncCallback(IASyncResultCallBack), client); } } catch (Exception s) { this.Invoke(new SetText(SetTextMethod), new object[] { s.Message }); } } void IASyncResultCallBack(IAsyncResult ar) { try { //get the tcp client instance TcpClient currentclient = ar.AsyncState as TcpClient; if (currentclient != null) { if (currentclient.GetStream().CanRead) { //get the instance of the data int count = (currentclient.GetStream()).EndRead(ar); if (count <= 0) { //disconnect the current client currentclient.Close(); currentclient = null; GC.Collect(); return; } //build the Received Text ReadText(data, 0, data.Length); } } //now begin Reading again lock (currentclient.GetStream()) { currentclient.GetStream().BeginRead(data, 0, data.Length, new AsyncCallback(IASyncResultCallBack), currentclient);
There's an amazing website that might help. It's called GOOGLE: Results 1 - 10 of about 4,310 for Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request. with Safesearch on. (0.24 seconds) :mad:
Panic, Chaos, Destruction. My work here is done.