Пример #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");
     }
 }
Пример #2
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();
        }
Пример #3
0
 public static EvHttpBoundSocket EvHttpAcceptSocketWithHandle(EvHttp http, IntPtr fd)
 {
     return Platform.RunningOnWindows ? EvHttpAcceptSocketWithHandleWindows(http, fd) : EvHttpAcceptSocketWithHandleNix(http, fd.ToInt32());
 }
Пример #4
0
 public static EvHttpBoundSocket EvHttpAcceptSocketWithHandle(EvHttp http, IntPtr fd)
 {
     return(Platform.RunningOnWindows ? EvHttpAcceptSocketWithHandleWindows(http, fd) : EvHttpAcceptSocketWithHandleNix(http, fd.ToInt32()));
 }