Exemple #1
0
        /// <summary>
        /// If the tunnel is connected, a new AnpTransport is created and the
        /// method returns true. Otherwise, the method returns false.
        /// </summary>
        public bool CheckConnect()
        {
            SelectSockets select = new SelectSockets();

            select.Timeout = 0;
            select.AddRead(tunnel.Sock);
            tunnel.CheckTls();
            select.Select();
            if (select.ReadSockets.Contains(tunnel.Sock))
            {
                CreateTransport();
                return(true);
            }
            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Send an AnpMsg. This method blocks if a message is currently being
 /// transferred.
 /// </summary>
 /// <param name="msg"></param>
 public void SendMsg(AnpMsg msg)
 {
     Debug.Assert(transport.isReceiving || transport.doneReceiving);
     while (transport.isSending)
     {
         SelectSockets select = new SelectSockets();
         transport.doXfer();
         UpdateSelect(select);
         if (transport.isSending)
         {
             select.Select();
         }
     }
     transport.sendMsg(msg);
     transport.doXfer();
 }
Exemple #3
0
        /// <summary>
        /// Block until the tunnel is connected or a timeout occurs. If the tunnel
        /// is connected, a new AnpTransport is created and the method returns true.
        /// Otherwise, the method returns false.
        /// </summary>
        /// <param name="timeout">Microseconds to wait in the Select.</param>
        public bool CheckConnect(int timeout)
        {
            // FIXME : loop to call tunnel.CheckTls()
            // at regular intervals.
            SelectSockets select = new SelectSockets();

            select.Timeout = timeout;
            select.AddRead(tunnel.Sock);
            tunnel.CheckTls();
            select.Select();
            if (select.ReadSockets.Contains(tunnel.Sock))
            {
                CreateTransport();
                return(true);
            }
            return(false);
        }
Exemple #4
0
        /// <summary>
        /// Get an AnpMsg. This is a blocking method, unless a message has already
        /// been received.
        /// </summary>
        public AnpMsg GetMsg()
        {
            Debug.Assert(transport.isReceiving || transport.doneReceiving);
            while (!transport.doneReceiving)
            {
                SelectSockets select = new SelectSockets();
                transport.doXfer();
                UpdateSelect(select);
                if (!transport.doneReceiving)
                {
                    select.Select();
                }
            }
            AnpMsg msg = transport.getRecv();

            transport.beginRecv();
            return(msg);
        }