• Register
0 votes
172 views

Problem :

I am facing following c# socket issue
the i/o operation has been aborted because of either a thread exit or an application request
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had also encountered the same issue with RS232 communication. The reason behind this issue is your program executes faster than the slow serial communication.

The solution of the issue is as follows :

Stream s = this.GetStream();
IAsyncResult ar = s.BeginWrite(data, 0, data.Length, SendAsync, state);
if (!ar.IsCompleted)
    ar.AsyncWaitHandle.WaitOne();

Please Note: Most of the time ar.IsCompleted is true.

9 7 4
38,600 points

Related questions

1 vote
1 answer 3 views
3 views
Problem: I keep getting these errors : System.Net.Sockets.SocketException (0x80004005): An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback ... (Environment.CurrentDirectory + "\\data\\fatal.txt", WhatToWrite); Program.Stop(); } }How can I solve this ?
asked May 5 Raj Tyagi 15.6k points
1 vote
1 answer 2 views
2 views
Problem: I’m getting errors from this part of my code : public void SendData(byte[] Data) { try { if (mSocket == null) { //Output.WriteLine("[SND] Socket has a null exception, which means it is now invalid. Remove this socket!", OutputLevel.CriticalError); } ... at iRP.Game.Sessions.Session.SendData(Byte[] Data)How can I solve them ? They are just occurring more and more on my game server .
asked May 1 Raj Tyagi 15.6k points
0 votes
1 answer 18 views
18 views
Problem: Hi there! I have written following code in C#: using System; public class HelloWorld { public static void Main() { string first_Name, last_Name; int Age, contact_Number; for(int i = 0; i<20; i++) { Console.Write("*"); } Console.WriteLine(); Console.Write ... value) at HelloWorld.Main() :line 23 I am unable to understand the cause of the exception. Can anybody help me sort it out? Thanks!
asked Mar 18 Code Learner 9.9k points
0 votes
1 answer 6 views
6 views
Problem: Can anyone tell me the solution of this problem? An operation on a socket could not be performed
asked Apr 7 Ifra 37.2k points
0 votes
1 answer 3 views
3 views
Problem: How to fix this error > Only part of a readprocessmemory or writeprocessmemory request was completed
asked Apr 30 ummeshani 10.8k points
0 votes
1 answer 19 views
19 views
Problem: Why I got the error > Established connection failed because connected host has failed to respond
asked May 1 ummeshani 10.8k points
0 votes
1 answer 6 views
6 views
Problem: I am not sure why this happens and I never explicitly abort threads, so it's a bit of a surprise. But I log Exceptions and I am seeing: System.Threading.ThreadAbortException - The thread was being aborted.
asked Mar 21 ummesalma 29.2k points
0 votes
1 answer 6 views
6 views
Problem: Official reasons for Software caused connection abort: socket write error,how can I resolve the error?
asked Apr 14 Humaira ahmed 50.7k points
0 votes
1 answer 13 views
13 views
Problem: packet_write_wait: connection to port 22: broken pipe, can anyone here who can answer me.
asked Apr 10 niyatiry 3.9k points
0 votes
1 answer 13 views
13 views
Problem: Please kindly tell me the solution of it, java.net.socketexception: broken pipe (write failed)
asked Apr 2 Ifra 37.2k points