TCP - The IO operation has been aborted because of either a thread exit or an application request

Hello, I am trying to implement a class that connects to a server through TCP, receives a message, opens a server, then sends a message through that server to all connected clients. This class seems to work, however, incrementally I will receive:
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Net.Sockets.Socket>.GetResult(Int16 token)
at System.Net.Sockets.TcpListener.<AcceptTcpClientAsync>g__WaitAndWrap|31_0(ValueTask`1 task)
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 153
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Net.Sockets.Socket>.GetResult(Int16 token)
at System.Net.Sockets.TcpListener.<AcceptTcpClientAsync>g__WaitAndWrap|31_0(ValueTask`1 task)
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 153
and then eventually:
System.InvalidOperationException: Not listening. You must call the Start() method before calling this method.
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 0
System.InvalidOperationException: Not listening. You must call the Start() method before calling this method.
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 0
https://hastebin.com/depiviqoci.csharp
Hastebin: Send and Save Text or Code Snippets for Free | Toptal®
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX2y ago
Determinism#3334
Well, I get
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Net.Sockets.Socket>.GetResult(Int16 token)
at System.Net.Sockets.TcpListener.<AcceptTcpClientAsync>g__WaitAndWrap|31_0(ValueTask`1 task)
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 153
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Net.Sockets.Socket>.GetResult(Int16 token)
at System.Net.Sockets.TcpListener.<AcceptTcpClientAsync>g__WaitAndWrap|31_0(ValueTask`1 task)
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 153
and then eventually:
System.InvalidOperationException: Not listening. You must call the Start() method before calling this method.
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 0
System.InvalidOperationException: Not listening. You must call the Start() method before calling this method.
at ReversingMill1CommsService.Worker.ConnectAndSend() in Worker.cs:line 0
Quoted by
React with ❌ to remove this embed.
Accord
Accord2y ago
✅ This post has been marked as answered!