Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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);
        }