Esempio n. 1
0
        public override void Listen(string host, int port, Action <Socket> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (state != Socket.SocketState.Invalid)
            {
                throw new InvalidOperationException("Socket already in use");
            }

            this.acceptCallback = callback;

            int error;
            int fd = manos_tls_listen(tlsContext, host, port, 128, out error);

            if (fd < 0)
            {
                if (error == 98)
                {
                    throw new Exception(String.Format("Address {0}::{1} is already in use.", host, port));
                }
                throw new Exception(String.Format("An error occurred while trying to liste to {0}:{1} errno: {2}", host, port, error));
            }

            state = Socket.SocketState.Listening;

            stream = new SecureSocketStream(this, new IntPtr(fd), tlsContext);
            stream.ResumeReading();
        }
Esempio n. 2
0
 SecureSocket(Context context, SocketInfo info, IntPtr tlsContext)
     : base(context, info)
 {
     stream          = new SecureSocketStream(this, new IntPtr(info.fd), tlsContext);
     this.tlsContext = tlsContext;
     this.state      = Socket.SocketState.Open;
 }
Esempio n. 3
0
 SecureSocket(IOLoop loop, SocketInfo info, IntPtr tlsContext)
     : base(loop, info)
 {
     stream = new SecureSocketStream (this, new IntPtr (info.fd), tlsContext);
     this.tlsContext = tlsContext;
     this.state = Socket.SocketState.Open;
 }
Esempio n. 4
0
 public override void Close()
 {
     if (stream != null) {
         stream.Close ();
         stream = null;
     }
     base.Close ();
 }
Esempio n. 5
0
 public override void Close()
 {
     if (stream != null)
     {
         stream.Close();
         stream = null;
     }
     base.Close();
 }
Esempio n. 6
0
        protected override void AcceptConnections()
        {
            int error = 0;

            while (error == 0)
            {
                IntPtr     client;
                SocketInfo accept_info;

                error = manos_tls_accept(tls, out client, out accept_info);
                if (error == 0)
                {
                    var clientStream = new SecureSocketStream(client, accept_info, EVIOLoop);
                    OnConnectionAccepted(clientStream);
                }
            }
        }
Esempio n. 7
0
        public override void Listen(string host, int port, Action<Socket> callback)
        {
            if (callback == null)
                throw new ArgumentNullException ("callback");

            if (state != Socket.SocketState.Invalid)
                throw new InvalidOperationException ("Socket already in use");

            this.acceptCallback = callback;

            int error;
            int fd = manos_tls_listen (tlsContext, host, port, 128, out error);

            if (fd < 0) {
                if (error == 98)
                    throw new Exception (String.Format ("Address {0}::{1} is already in use.", host, port));
                throw new Exception (String.Format ("An error occurred while trying to liste to {0}:{1} errno: {2}", host, port, error));
            }

            state = Socket.SocketState.Listening;

            stream = new SecureSocketStream (this, new IntPtr (fd), tlsContext);
            stream.ResumeReading ();
        }
Esempio n. 8
0
        protected override void AcceptConnections()
        {
            int error = 0;

            while (error == 0) {
                IntPtr client;
                SocketInfo accept_info;

                error = manos_tls_accept (tls, out client, out accept_info);
                if (error == 0) {
                    var clientStream = new SecureSocketStream (client, accept_info, EVIOLoop);
                    OnConnectionAccepted (clientStream);
                }
            }
        }