コード例 #1
0
        public override void  handle_work(AsyncWork ar)
        {
            byte [] buffer = (byte [])ar.item();

            // Craete a new timer and send the buffer
            //AsyncTimer t = new AsyncTimer();
            //t.open(this, 0);
            //t.work(1, buffer);

            // start a new work
            m_async_send.send(buffer);
            //m_async_work.work();
            m_event_queue.getQ(ar);
        }
コード例 #2
0
        public virtual int open(Socket sock)
        {
            m_sock = sock;

            // Setting non-blocking mode has no effect on async calls
            //sock.Blocking = false;
            // Issue the first work
            m_async_work.open(this);
            m_event_queue.getQ(m_async_work);
            //m_async_work.work();
            //m_event_queue.getQ(m_async_work);

            m_async_receive.open(this, m_sock);
            m_async_init.open(this, m_sock);
            m_async_send.open(this, m_sock);
            // Begin reading bytes from the socket and echo them all back
            byte [] buffer = new byte[128];
            m_async_receive.receive(buffer);


            byte [] message = new byte[128];
            message = Encoding.ASCII.GetBytes("hello");

            m_async_init.send(message);

            return(0);
        }