VB.NET 3.5 SocketException bei der Bereitstellung, jedoch nicht auf dem Entwicklungscomputer
Ich habe einen asynchronen UDP-Client geschrieben, um mit einem Server in meiner Firma zu kommunizieren. Wenn ich auf meinem Entwicklercomputer laufe, ist alles in Ordnung. Bei der Bereitstellung auf einem anderen Computer wird bei EndReceive eine Socket-Ausnahme angezeigt, wenn ich zum ersten Mal Daten über den Socket sende. Meine Entwicklungsbox ist Win7, und ich habe sie sowohl auf einem XP SP3-Computer als auch auf einem Server 2003 R2-Computer bereitgestellt. Unten ist der Empfangscode:
Private Sub ReceiveCallback(ByVal ar As IAsyncResult)
Try
' Retrieve the state object and the client socket
from the asynchronous state object.'
Dim state As StateObj = CType(ar.AsyncState, StateObj)
Dim client As Socket = state.sockArg
' Read data from the remote device.'
Dim bytesRead As Integer
receiveDone.WaitOne(Timeout.Infinite)
bytesRead = client.EndReceive(ar)
If bytesRead > 0 Then
Dim s As String = Encoding.ASCII.GetString(state.buffer, 0, bytesRead)
parsedata(s)
End If
Catch SockEx As SocketException
mlog.Error(String.Format("ID={1} {0} SocketError={2}", SockEx.Message, ID.ToString, SockEx.SocketErrorCode.ToString), SockEx)
Catch ox As System.ObjectDisposedException
mlog.Warn(String.Format("Object Disposed ID={0}", ID.ToString))
Catch ex As Exception
mlog.Error(String.Format("{1} ID={0}", ID.ToString, ex.Message), ex)
End Try
End Sub 'ReceiveCallback
Die Ausnahme, die ich bekomme, ist:
System.Net.Sockets.SocketException: Die E / A-Operation wurde aufgrund eines Thread-Exits oder einer Anwendungsanforderung bei System.Net.Sockets.Socket.EndReceive (IAsyncResult asyncResult) bei RTSPc.Connection.ReceiveCallback (IAsyncResult ar) abgebrochen.
Die SocketException ist OperationAborted