Ejemplo n.º 1
0
    static public int RECV_BUFFER_SIZE = 10 * 1024 * 1024; //!< Size of the buffer for read operations

    // Use this for initialization
    public NetworkEyeConnection(string host, Int32 port)
    {
        m_state = SensoNetworkState.SENSO_DISCONNECTED;
        m_port  = port;
        if (IPAddress.TryParse(host, out m_ip))
        {
            doConnect();
        }
    }
Ejemplo n.º 2
0
 private void doConnect()
 {
     m_sock         = new TcpClient(AddressFamily.InterNetwork);
     m_sock.NoDelay = true;
     if (m_state == SensoNetworkState.SENSO_DISCONNECTED)
     {
         var connectCB = new AsyncCallback(ProcessConnectResult);
         m_connectRes = m_sock.BeginConnect(m_ip, m_port, connectCB, null);
         m_state      = SensoNetworkState.SENSO_CONNECTING;
     }
 }
Ejemplo n.º 3
0
 public void Disconnect()
 {
     try
     {
         if (m_state == SensoNetworkState.SENSO_CONNECTING)
         {
             m_sock.EndConnect(m_connectRes);
         }
         else if (m_state == SensoNetworkState.SENSO_CONNECTED)
         {
             m_sock.Close();
         }
     } catch (Exception ex)
     {
         Debug.Log("Disconnect error: " + ex.Message);
     }
     IsReceiving = false;
     m_stream    = null;
     m_sock      = null;
     m_state     = SensoNetworkState.SENSO_DISCONNECTED;
 }
Ejemplo n.º 4
0
 // The following method is called when each asynchronous operation completes.
 void ProcessConnectResult(IAsyncResult result)
 {
     try
     {
         m_sock.EndConnect(result);
     } catch (Exception ex)
     {
         // eat the exception
     }
     if (m_sock.Connected)
     {
         Debug.Log("Connected to Eye Server");
         m_sock.SendTimeout = 100;
         m_stream           = m_sock.GetStream();
         m_state            = SensoNetworkState.SENSO_CONNECTED;
     }
     else
     {
         Debug.Log("Unable to connect to Eye Server");
         m_stream = null;
         m_state  = SensoNetworkState.SENSO_DISCONNECTED;
     }
 }