public override bool Start() { try { Sock.BeginReceiveFrom(Pack, 0, Pack.Size, SocketFlags.None, ref SocketSettings.ServerEndPoint, ReceivedCallback, obj); State = SocketState.Started; } catch (Exception ex) { EventProvider.ExecuteErrorHandler(ex, SocketErrorLocation.BeginStart); return(false); } return(true); }
private void ReceivedCallback(IAsyncResult asyncResult) { try { ReceivedDataLen = Sock.EndReceiveFrom(asyncResult, ref SocketSettings.ServerEndPoint); } catch (SocketException) { return; } catch (ObjectDisposedException) { return; } if (ReceivedDataLen > 0) { EventProvider.ExecuteReceivedDataHandler(Pack.Clone(), this); Array.Clear(Pack, 0, Pack.Size); } Sock.BeginReceiveFrom(Pack, 0, Pack.Size, SocketFlags.None, ref SocketSettings.ServerEndPoint, ReceivedCallback, obj); }