TcpSocket(Context context, AddressFamily addressFamily, int fd, IPEndPoint local, IPEndPoint remote) : base(context, addressFamily, fd) { this.stream = new TcpSocketStream(this, new IntPtr(fd)); this.localname = local; this.peername = remote; this.IsConnected = true; this.IsBound = true; }
protected override void Dispose(bool disposing) { if (listener != null) { listener.Stop(); listener.Dispose(); listener = null; } if (stream != null) { stream.Close(); stream = null; } base.Dispose(disposing); }
public override IByteStream GetSocketStream() { CheckDisposed(); if (!IsConnected) { throw new SocketException("Not conntected", SocketError.NotConnected); } if (listener != null) { throw new InvalidOperationException(); } if (stream == null) { stream = new TcpSocketStream(this, new IntPtr(fd)); } return(stream); }