protected override void Dispose(bool disposing) { if (parent != null) { RaiseEndOfStream(); receiveBuffer = null; parent = null; } base.Dispose(disposing); }
public void Listen(int backlog, Action <ITcpSocket> callback) { CheckDisposed(); if (stream != null) { throw new InvalidOperationException(); } if (listener != null) { listener.Stop(); listener.Dispose(); } int error; var result = SocketFunctions.manos_socket_listen(fd, backlog, out error); if (result < 0) { throw Errors.SocketFailure("Listen failure", error); } listener = new IOWatcher(new IntPtr(fd), EventTypes.Read, Context.Loop, delegate { ManosIPEndpoint ep; var client = SocketFunctions.manos_socket_accept(fd, out ep, out error); if (client < 0 && error != 0) { throw new Exception(string.Format("Error while accepting: {0}", Errors.ErrorToString(error))); } else if (client > 0) { var socket = new TcpSocket(Context, AddressFamily, client, LocalEndpoint, ep); callback(socket); } }); listener.Start(); }
public TcpSocketStream(TcpSocket parent, IntPtr handle) : base(parent.Context, handle) { this.parent = parent; }