void WriteDataSync(ISocket socket) { foreach (var d in MakeData()) { Debug.WriteLine("Client writing data sync."); socket.Write(new ArraySegment <byte>(d), null); } Debug.WriteLine("Client ending connection."); socket.End(); }
public void Simple_handshake_client_closes_connection() { serverDelegate.OnConnectionAction = (server, socket) => { Debug.WriteLine("server OnConnection"); serverSocketDelegate = new SocketDelegate(); serverSocketDelegate.OnEndAction = () => { Debug.WriteLine("serverSocket OnEnd"); socket.End(); }; serverSocketDelegate.OnCloseAction = () => { Debug.WriteLine("serverSocket OnClose"); socket.Dispose(); }; return(serverSocketDelegate); }; schedulerStartedAction = () => { clientSocketDelegate.OnConnectedAction = () => { Debug.WriteLine("client End"); client.End(); }; clientSocketDelegate.OnCloseAction = () => { Debug.WriteLine("client OnClose"); scheduler.Stop(); }; client.Connect(ep); }; RunScheduler(); AssertConnectionAndCleanShutdown(); }
// called if error on socket or whilst parsing, or if user code cancels request input public void OnError(Exception e) { if (tail == null) { socket.End(); } else { // dispose all pending responses, last of which should end the socket tail.Dispose(); } }
public void End_before_connect_throws_exception() { Exception ex = null; schedulerStartedAction = () => { try { client.End(); } catch (InvalidOperationException e) { ex = e; } scheduler.Stop(); }; RunScheduler(); Assert.That(ex, Is.Not.Null); Assert.That(ex.Message, Is.EqualTo("The socket was not connected.")); }
void WriteDataAsync(ISocket socket, IEnumerator <byte[]> ds) { if (ds.MoveNext()) { Debug.WriteLine("Client writing data async."); if (!socket.Write(new ArraySegment <byte>(ds.Current), () => WriteDataAsync(socket, ds))) { WriteDataAsync(socket, ds); } } else { Debug.WriteLine("Client ending connection."); ds.Dispose(); socket.End(); } }
public void OnEnd() { socket.End(); }
void WriteDataSync(ISocket socket) { foreach (var d in MakeData()) { Debug.WriteLine("Client writing data sync."); socket.Write(new ArraySegment<byte>(d), null); } Debug.WriteLine("Client ending connection."); socket.End(); }
void WriteDataAsync(ISocket socket, IEnumerator<byte[]> ds) { if (ds.MoveNext()) { Debug.WriteLine("Client writing data async."); if (!socket.Write(new ArraySegment<byte>(ds.Current), () => WriteDataAsync(socket, ds))) WriteDataAsync(socket, ds); } else { Debug.WriteLine("Client ending connection."); ds.Dispose(); socket.End(); } }