Exemple #1
0
        public bool Accept(CTcpClientSocket socket)
        {
            if (m_sock == null || !IsOpen)
            {
                m_error = "socket closed";
                return(false);
            }

            bool returnv = WaitForSocket(false, "Accept");  //wait for socket to become readable

            if (!returnv)
            {
                return(false);
            }

            try
            {
                Socket acceptedSocket = m_sock.Accept();
                //int sock = accept(m_sock, reinterpret_cast <struct sockaddr*>(&client), &clientlen);

                if (!socket.SetInfo(acceptedSocket))
                {
                    m_error = socket.GetError();
                    return(false);
                }
            }
            catch (SocketException sockEx)
            {
                m_error = "select() " + m_address + ":" + m_port + " " + sockEx.NativeErrorCode + " " + sockEx.SocketErrorCode; //TODO: format this better
                return(false);
            }

            return(true);
        }
Exemple #2
0
 public CClient()
 {
     m_socket       = new CTcpClientSocket();
     m_lightnrs     = new Dictionary <string, int>();
     m_messagequeue = new CMessageQueue();
 }