private void AcceptCallback(IAsyncResult ar) { ThreadNotifier.Set(); Listener = (Socket)ar.AsyncState; CurrentClient = new ClientSocketAsync(Listener.EndAccept(ar)); OnClientAccepted?.Invoke(this, CurrentClient); }
public async Task acceptClient() { OnListeningForClient.Invoke(this, new ServerEventArgs("Server Accepting Clients.")); client = await server.AcceptTcpClientAsync(); OnClientAccepted.Invoke(this, new ServerEventArgs("Server Accepted Client.")); }
/// <summary> /// Process a new connected client. /// </summary> /// <param name="socketAsyncEvent">Socket async event arguments.</param> private void ProcessAccept(SocketAsyncEventArgs socketAsyncEvent) { if (socketAsyncEvent.SocketError == SocketError.Success) { OnClientAccepted?.Invoke(this, socketAsyncEvent); StartAccept(); } }
private void EndAccept(IAsyncResult iar) { try { var socket = m_sock.EndAccept(iar); OnClientAccepted?.Invoke(socket); } catch (ObjectDisposedException) { } catch (SocketException) { } finally { BeginAccept(); } }
/// <summary> /// Process a new connected client. /// </summary> /// <param name="socketAsyncEvent">Socket async event arguments.</param> private void ProcessAccept(SocketAsyncEventArgs socketAsyncEvent) { if (socketAsyncEvent.SocketError == SocketError.Success) { try { OnClientAccepted?.Invoke(this, socketAsyncEvent); } catch (Exception exception) { OnError?.Invoke(this, exception); } StartAccept(); } }
private void EndAccept(IAsyncResult iar) { try { Event.Set(); var socket = Socket.EndAccept(iar); OnClientAccepted?.Invoke(socket); } catch (ObjectDisposedException) { //Nothing } catch (Exception ex) { OnException?.Invoke(ex); } }