PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework
Problem with UDP socket under NET Framework
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework
Problem with UDP socket under NET Framework
![]() |
Problem with UDP socket under NET Framework |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have a problem with using UPD under NET framwork.
The problem consist if any client disconnect under UDP protocol from server ( code below ) it raise exeption 10054 - It shouldn't be under UDP protocol - becouse this protocol is connectionless and does not have any notification about closing. Exeption 10054 is: An existing connection was forcibly closed by the remote host. Thanks, Volodia. UDP server code (by the way - client done in unmanaged C++) : Sub ThreadProc() _ReceivingSocket = New Socket(AddressFamily.InterNetwork, _ SocketType.Dgram, ProtocolType.Udp) _ReceivingSocket.SetSocketOption(SocketOptionLevel.Socket, _ SocketOptionName.ReuseAddress, 1) Dim listenEndPoint As IPEndPoint = New IPEndPoint(IPAddress.Any, _Port) _ReceivingSocket.Bind(listenEndPoint) Dim state As New StateObject Dim nodecallback As New AsyncCallback(AddressOf RecieveCallback) Dim nodeIP As IPEndPoint = New IPEndPoint(IPAddress.Any, 0) Dim nodeEP As EndPoint = DirectCast(nodeIP, EndPoint) While NodeListenerRun > 0 ReadDone.Reset() Try _ReceivingSocket.BeginReceiveFrom(state.buffer, 0, _ state.BufferSize, SocketFlags.None, nodeEP, nodecallback, state) ReadDone.WaitOne() Catch sex As SocketException If (sex.ErrorCode = 10040) Then state.IncreaseBuffer() Else SwitchSocketOff() End If Catch exp As Exception CloseListening() End Try End While End sub Private Shared Sub RecieveCallback(ByVal ar As IAsyncResult) Try ' ' Get state object ' Dim state As StateObject = CType(ar.AsyncState, StateObject) ' ' Creates a temporary EndPoint to pass to EndReceiveFrom. ' Dim sender As New IPEndPoint(IPAddress.Any, 0) Dim fromEP As EndPoint = CType(sender, EndPoint) ' ' Get number of bytes. ' Dim bytesRead As Integer = state.workSocket.EndReceiveFrom(ar, fromEP) Dim str As String If bytesRead > 0 Then str = Encoding.ASCII.GetChars(state.buffer, 0, bytesRead) ' ' Process data ' ClientResponce(state, fromEP, str) End If Catch sex As SocketException If (sex.ErrorCode = 10054) Then SwitchSocketOff() Tracing("Listener RecieveCallback : " & sex.Message) End If Catch ex As Exception Tracing("Listener RecieveCallback error: " & ex.ToString) End Try ' ' All data was get, so reset event. ' ReadDone.Set() End Sub |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Volodia <GroundSoft@hotmail.com> wrote:
> I have a problem with using UPD under NET framwork. > The problem consist if any client disconnect under UDP protocol > from server ( code below ) it raise exeption 10054 - [...] See http://support.microsoft.com/?kbid=263823 "263823 - WinSock Recvfrom() Now Returns WSAECONNRESET Instead of Blocking or Timing Out". -- Alan J. McFarlane http://homepage.ntlworld.com/alanjmcf/ Please follow-up in the newsgroup for the benefit of all. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thanks.
"Alan J. McFarlane" <alanjmcf@yahoo.com> wrote in message news:sVCOa.5230$ju6.94457@newsfep4-glfd.server.ntli.net... > Volodia <GroundSoft@hotmail.com> wrote: > > I have a problem with using UPD under NET framwork. > > The problem consist if any client disconnect under UDP protocol > > from server ( code below ) it raise exeption 10054 - > [...] > See http://support.microsoft.com/?kbid=263823 "263823 - WinSock Recvfrom() > Now Returns WSAECONNRESET Instead of Blocking or Timing Out". > -- > Alan J. McFarlane > http://homepage.ntlworld.com/alanjmcf/ > Please follow-up in the newsgroup for the benefit of all. > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

