Example #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();
        }
Example #2
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 ();
        }