Example #1
0
            /// <summary>Connects to a server.</summary>
            /// <param name="serverIpAddress">Server's IP address.</param>
            /// <param name="serverPort">Server's port.</param>
            /// <param name="readCallback">Callback for read operations.</param>
            /// <param name="disconnect">Whether to disconnect if already connected.</param>
            /// <returns>True if the operation was successful, False otherwise.</returns>
            public bool Connect(string serverIpAddress, UInt16 serverPort, ClientReadCallback readCallback = null, bool disconnect = true)
            {
                IPAddress ipAddress;
                bool      parsingResult = IPAddress.TryParse(serverIpAddress, out ipAddress);

                if (parsingResult == false)
                {
                    ipAddress = Dns.GetHostEntry(serverIpAddress).AddressList[0];
                }

                return(Connect(ipAddress, serverPort, readCallback, disconnect));
            }
Example #2
0
            /// <summary>Connects to a server.</summary>
            /// <param name="serverIpAddress">Server's IP address.</param>
            /// <param name="serverPort">Server's port.</param>
            /// <param name="readCallback">Callback for read operations.</param>
            /// <param name="disconnect">Whether to disconnect if already connected.</param>
            /// <returns>True if the operation was successful, False otherwise.</returns>
            public bool Connect(IPAddress serverIpAddress, UInt16 serverPort, ClientReadCallback readCallback = null, bool disconnect = true)
            {
                m_ReadCallback = null;

                if (disconnect == true)
                {
                    Disconnect();
                }

                if (m_Connected == true)
                {
                    return(false);
                }

                if (TryToConnect(serverIpAddress, serverPort) == true)
                {
                    m_Connected    = true;
                    m_ReadCallback = readCallback;
                    return(true);
                }

                return(false);
            }
Example #3
0
 /// <summary>Sets read operations callback.</summary>
 /// <param name="readCallback">Callback for read operations.</param>
 public void SetReadCallback(ClientReadCallback readCallback)
 {
     m_ReadCallback = readCallback;
 }