Inheritance: System.Runtime.InteropServices.SafeHandle
Exemplo n.º 1
0
 public EventHttpListener(RequestCallback cb)
 {
     LibLocator.TryToLoadDefaultIfNotInitialized();
     _cb = cb;
     _eventBase = Event.EventBaseNew();
     if (_eventBase.IsInvalid)
         throw new IOException("Unable to create event_base");
     _evHttp = Event.EvHttpNew(_eventBase);
     if (_evHttp.IsInvalid)
     {
         Dispose();
         throw new IOException("Unable to create evhttp");
     }
 }
Exemplo n.º 2
0
 public EvUserEvent(EventBase evBase)
 {
     if (Platform.RunningOnWindows)
     {
         var winCb = new Event.D.event_callback_windows(CallbackWin);
         _winCbHandle = GCHandle.Alloc(winCb);
         _event = Event.EventNewWindows(evBase, new IntPtr(-1), 0, winCb, IntPtr.Zero);
     }
     else
     {
         var nixCb = new Event.D.event_callback_normal(CallbackNix);
         _nixCbHandle = GCHandle.Alloc(nixCb);
         _event = Event.EventNewNix(evBase, -1, 0, nixCb, IntPtr.Zero);
     }
 }
Exemplo n.º 3
0
        public void Start(string host, ushort port)
        {
            _eventBase = Event.EventBaseNew();
            if (_eventBase.IsInvalid)
                throw new IOException("Unable to create event_base");
            _evHttp = Event.EvHttpNew(_eventBase);
            if (_evHttp.IsInvalid)
            {
                Dispose();
                throw new IOException ("Unable to create evhttp");
            }
            _socket = Event.EvHttpBindSocketWithHandle(_evHttp, host, port);
            if (_socket.IsInvalid)
            {
                Dispose();
                throw new IOException("Unable to bind to the specified address");
            }

            _thread = new Thread(MainCycle) {Priority = ThreadPriority.Highest};
            _thread.Start();
        }
Exemplo n.º 4
0
        public static EvConnListener EvConnListenerNew(EventBase evBase, IntPtr cb, IntPtr ptr, uint flags, int backlog, IntPtr fd)
        {
            return Platform.RunningOnWindows
                       ? EvConnListenerNewWindows(evBase, cb, ptr, flags, backlog, fd)

                       : EvConnListenerNewNix(evBase, cb, ptr, flags, backlog, fd.ToInt32());
        }