コード例 #1
0
        public async Task <(bool, string)> ConnectAsync(string ip, int port)
        {
            try
            {
                Client         = null;
                Client         = new TcpClient();
                Client.NoDelay = true;

                await Client.ConnectAsync(ip, port);

                DummyManager.DummyConnected();
                return(true, "");
            }
            catch (Exception ex)
            {
                LastExceptionMessage = ex.Message;
                return(false, ex.Message);
            }
        }
コード例 #2
0
        public async Task <(bool, int, string)> ConnectAsync(string ip, int port)
        {
            try
            {
                Conn.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                await Conn.ConnectAsync(ip, port);

                Conn.NoDelay = true;

                DummyManager.DummyConnected();

                IsConnectToDisconnected = false;
                return(true, 0, "");
            }
            catch (Exception ex)
            {
                var sockEx = (SocketException)ex;
                LastExceptionMessage = sockEx.Message;
                return(false, sockEx.ErrorCode, sockEx.Message);
            }
        }