我使用异步套接字创建了一个服务器 - 客户端应用程序。我在服务器上关闭套接字时发现问题,应用程序如此关闭。我关闭套接字服务器的过程是:
当我关闭服务器套接字时,如何阻止应用程序关闭?感谢
Protected Friend Sub CloseServerSocket(ByVal IPAddress As IPAddress, ByVal socketPort As Integer)
' Terminate the listening thread.
If listeningThread.IsAlive Then listeningThread.Abort()
' Close the client socket is still connected to the server.
For Each sock As Socket In workSocketList
If sock.Connected Then
Interlocked.Decrement(workCount)
sock.Close()
End If
Next
' Close the server socket.
serverSocket.Close()
serverSocket = Nothing
End Sub
答案 0 :(得分:0)
Protected Friend Sub CloseServerSocket(ByVal IPAddress As IPAddress, ByVal socketPort As Integer)
' Terminate the listening thread.
If listeningThread.IsAlive Then listeningThread.Abort()
' Close the server socket.
serverSocket.Close()
serverSocket = Nothing
' Close the client socket is still connected to the server.
For Each sock As Socket In workSocketList
If sock.Connected Then
Interlocked.Decrement(workCount)
sock.Close()
End If
Next
End Sub