コード例 #1
0
ファイル: SecureSocket.cs プロジェクト: kersny/manos
        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();
        }
コード例 #2
0
ファイル: SecureSocket.cs プロジェクト: kersny/manos
 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;
 }
コード例 #3
0
ファイル: SecureSocket.cs プロジェクト: restrepo/manos
 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;
 }
コード例 #4
0
ファイル: SecureSocket.cs プロジェクト: restrepo/manos
 public override void Close()
 {
     if (stream != null) {
         stream.Close ();
         stream = null;
     }
     base.Close ();
 }
コード例 #5
0
ファイル: SecureSocket.cs プロジェクト: kersny/manos
 public override void Close()
 {
     if (stream != null)
     {
         stream.Close();
         stream = null;
     }
     base.Close();
 }
コード例 #6
0
ファイル: SecureSocketStream.cs プロジェクト: aaronfeng/manos
        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);
                }
            }
        }
コード例 #7
0
ファイル: SecureSocket.cs プロジェクト: restrepo/manos
        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 ();
        }
コード例 #8
0
ファイル: SecureSocketStream.cs プロジェクト: aaronfeng/manos
        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);
                }
            }
        }