Example #1
0
        public void Start()
        {
            //			ioloop.AddHandler (Socket.Handle, HandleEvents, IOLoop.EPOLL_READ_EVENTS);

            iowatcher = new IOWatcher (Socket.Handle, EventTypes.Read, ioloop.EventLoop, HandleIOEvents);
            iowatcher.Start ();
        }
Example #2
0
        public override void Connect(string host, int port, Action callback)
        {
            if (state != Socket.SocketState.Invalid)
                throw new InvalidOperationException ("Socket already in use");

            int error;
            var fd = manos_socket_connect (host, port, out error);

            if (fd < 0)
                throw new Exception (String.Format ("An error occurred while trying to connect to {0}:{1} errno: {2}", host, port, error));

            stream = new PlainSocketStream (this, new IntPtr (fd));

            var connectWatcher = new IOWatcher (new IntPtr (fd), EventTypes.Write, Context.Loop, (watcher, revents) => {
                watcher.Stop ();
                watcher.Dispose ();

                this.address = host;
                this.port = port;

                this.state = Socket.SocketState.Open;

                callback ();
            });
            connectWatcher.Start ();
        }
Example #3
0
 public void Start()
 {
     handle = IOWatcher.GetHandle (Socket);
     iowatcher = new IOWatcher (handle, EventTypes.Read, ioloop.EventLoop, HandleIOEvents);
     iowatcher.Start ();
 }
Example #4
0
 public void Start()
 {
     iowatcher = new IOWatcher (Socket.Handle, EventTypes.Read, ioloop.EventLoop, HandleIOEvents);
     iowatcher.Start ();
 }
Example #5
0
        public void Listen( string host, int port )
        {
            int error;
            fd = manos_dgram_socket_listen( host, port, out error );

            if (fd < 0)
                throw new Exception (String.Format ("An error occurred while trying to connect to {0}:{1} errno: {2}", host, port, error));

            watcher = new IOWatcher( new IntPtr( fd ), EventTypes.Read, loop.EventLoop, (l, w, r) => onRead() );
            watcher.Start();
        }
Example #6
0
        public void Connect(string host, int port)
        {
            int error;
            fd = manos_socket_connect (host, port, out error);

            if (fd < 0)
                throw new Exception (String.Format ("An error occurred while trying to connect to {0}:{1} errno: {2}", host, port, error));

            IOWatcher iowatcher = new IOWatcher (new IntPtr (fd), EventTypes.Write, IOLoop.EventLoop, (l, w, r) => {
                w.Stop ();

                this.host = host;
                this.port = port;
                OnConnected ();
            });
            iowatcher.Start ();
        }
Example #7
0
        public void Connect(string host, int port)
        {
            socket = CreateSocket ();
            socket.Connect (host, port);

            IntPtr handle = IOWatcher.GetHandle (socket);
            IOWatcher iowatcher = new IOWatcher (handle, EventTypes.Write, IOLoop.EventLoop, (l, w, r) => {
                w.Stop ();
                OnConnected ();
            });
            iowatcher.Start ();
        }