Exemplo n.º 1
0
 public void SetUp()
 {
     connectedEndpoint = null;
     eventBase = new EventBase();
     listener = new ConnectionListener(eventBase, TestEndPoint, TestBacklog);
     listener.ConnectionAccepted = ConnectionAccepted;
     client = new TcpClient();
 }
Exemplo n.º 2
0
 public void SetUp()
 {
     eventBase = new EventBase();
     listener = new ConnectionListener(eventBase, EVConnListenerTests.TestEndPoint, EVConnListenerTests.TestBacklog);
     listener.ConnectionAccepted = ConnectionAccepted;
     client = new TcpClient();
     readData = new MemoryStream();
 }
Exemplo n.º 3
0
        public Event(EventBase eventBase, IntPtr fd, Events what)
        {
            this.fd = fd;
            cb = Delegate.CreateDelegate(typeof(event_callback_fn), this, "EventCallbackInternal");

            fp = Marshal.GetFunctionPointerForDelegate(cb);
            Debug.WriteLine("EVEvent created with fd " + fd.ToInt32().ToString("x") + ", cb " + fp.ToInt32().ToString("x"));
            Handle = event_new(eventBase.Handle, fd, (short)what, fp, IntPtr.Zero);
        }
Exemplo n.º 4
0
        public BufferEvent(EventBase eventBase, IntPtr socket)
        {
            var options = (int)(BufferEventOptions.CloseOnFree | BufferEventOptions.DeferCallbacks);
            bev = bufferevent_socket_new(eventBase.Handle, socket, options);
            //Console.WriteLine("bufferevent_socket_new returned " + bev.ToInt32());

            // none of these can throw exceptions.
            var readCb = Marshal.GetFunctionPointerForDelegate(new bufferevent_data_cb(ReadCallbackInternal));
            var writeCb = Marshal.GetFunctionPointerForDelegate(new bufferevent_data_cb(WriteCallbackInternal));
            var eventCb = Marshal.GetFunctionPointerForDelegate(new bufferevent_event_cb(EventCallbackInternal));

            bufferevent_setcb(bev, readCb, writeCb, eventCb, IntPtr.Zero);
        }
Exemplo n.º 5
0
        public ConnectionListener(EventBase eventBase, IPEndPoint endpoint, short backlog)
        {
            Base = eventBase;
            ListenEndPoint = endpoint;

            var options = (short)(ConnectionListenerOptions.CloseOnFree | ConnectionListenerOptions.Reusable);
            var socketAddr = sockaddr_in.FromIPEndPoint(endpoint);
            cb = Delegate.CreateDelegate(typeof(evconnlistener_cb), this, "ConnectionCallback");
            var callbackPointer = Marshal.GetFunctionPointerForDelegate(cb);

            lev = evconnlistener_new_bind(eventBase.Handle, callbackPointer, IntPtr.Zero,
                options, backlog, ref socketAddr, sockaddr_in.StructureLength);

            if (lev == IntPtr.Zero)
                throw new Exception("could not create ConnectionListener");
        }
Exemplo n.º 6
0
        public BufferEvent(EventBase eventBase, IntPtr socket, int timeout)
        {
            var options = (int)(BufferEventOptions.CloseOnFree | BufferEventOptions.DeferCallbacks);
            bev = bufferevent_socket_new(eventBase.Handle, socket, options);
            var t = timeval.FromTimeSpan(TimeSpan.FromMilliseconds(timeout));
            bufferevent_set_timeouts(bev, ref t, ref t);
            //Console.WriteLine("bufferevent_socket_new returned " + bev.ToInt32());

            // none of these can throw exceptions.
            readdel = new bufferevent_data_cb(ReadCallbackInternal);
            var readCb = Marshal.GetFunctionPointerForDelegate(readdel);
            writedel = new bufferevent_data_cb(WriteCallbackInternal);
            var writeCb = Marshal.GetFunctionPointerForDelegate(writedel);
            eventdel = new bufferevent_event_cb(EventCallbackInternal);
            var eventCb = Marshal.GetFunctionPointerForDelegate(eventdel);

            bufferevent_setcb(bev, readCb, writeCb, eventCb, IntPtr.Zero);
        }
Exemplo n.º 7
0
 public static Event CreateTimer(EventBase eventBase, bool persist)
 {
     return new Event(eventBase, new IntPtr(-1), persist ? Events.EV_PERSIST : Events.None);
 }
Exemplo n.º 8
0
 public static Event CreateTimer(EventBase eventBase)
 {
     return CreateTimer(eventBase, false);
 }
Exemplo n.º 9
0
 public void SetUp()
 {
     eventBase = new EventBase();
 }
Exemplo n.º 10
0
 public OarsSocketListener()
 {
     _eventBase = new EventBase ();
 }
Exemplo n.º 11
0
 internal OarsSocket(EventBase eventBase, IntPtr socket, IPEndPoint remoteEndPoint)
 {
     this.eventBase = eventBase;
     this.socket = socket;
     RemoteEndPoint = remoteEndPoint;
 }
Exemplo n.º 12
0
 public OarsServer(EventBase eventBase)
 {
     this.eventBase = eventBase;
 }
Exemplo n.º 13
0
 public OarsSocketListener()
 {
     _eventBase = new EventBase();
 }