当前位置: 首页>>代码示例>>C#>>正文


C# TcpClient.GetHashCode方法代码示例

本文整理汇总了C#中System.Net.Sockets.TcpClient.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# TcpClient.GetHashCode方法的具体用法?C# TcpClient.GetHashCode怎么用?C# TcpClient.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Sockets.TcpClient的用法示例。


在下文中一共展示了TcpClient.GetHashCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessTcpClient

        static void ProcessTcpClient(TcpClient client)
        {
            try
            {
                SslStream stream = new SslStream(client.GetStream());
                X509Certificate cert = new X509Certificate2(Certificate.CreateSelfSignCertificatePfx(
                    "CN=localhost", //host name
                    DateTime.Parse("2000-01-01"), //not valid before
                    DateTime.Parse("2099-01-01"), //not valid after
                    "mypassword"), "mypassword"); //password to encrypt key file)
                stream.AuthenticateAsServer(cert);

                byte[] requestBuffer = new byte[8192];
                int read = stream.Read(requestBuffer, 0, 8192);
                Array.Resize<byte>(ref requestBuffer, read);

                string request = Encoding.UTF8.GetString(requestBuffer);
                string requestedPath = request.Split('?')[0].Replace("GET ", "");

                Console.WriteLine(client.GetHashCode() + " => " + requestedPath);

                string response = "";

                if (requestedPath == "/gamepad/shardlist")
                {
                }
                else if (requestedPath == "/gamepad/lastshard")
                {
                }

                string header = "HTTP/1.1 200 OK\r\nDate: Fri, 10 Feb 2012 09:19:00 GMT\r\nServer: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o\r\nContent-Length: " + response.Length + "\r\nContent-Type: text/html\r\n\r\n";

                byte[] headerBytes = Encoding.UTF8.GetBytes(header);
                byte[] responseBytes = Encoding.UTF8.GetBytes(response);
                stream.Write(headerBytes);
                stream.Flush();
                stream.Write(responseBytes);
                stream.Flush();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occured!\nMessage: " + e.Message + "\n" + e.StackTrace);
            }
        }
开发者ID:Besyaka,项目名称:swtor-emu,代码行数:44,代码来源:Program.cs

示例2: ClientHandler

 public ClientHandler(TcpClient client,int id,GameHandler game)
 {
     Client = client;
     _game = game;
     FugamId = new FugamID(Client.GetHashCode(),id);
     _clientThread = new Thread(new ThreadStart(ClientThread));
     ServerIO.Send(Client.GetStream(),new PacketFugamID(FugamId));
 }
开发者ID:Jannickvb,项目名称:fugam,代码行数:8,代码来源:ClientHandler.cs

示例3: HandleReceive

        public static void HandleReceive(TcpClient client)
        {
            LogHelper.ShowLog("Receive connect\t" + DateTime.Now.ToString() + "\t" +
             client.GetHashCode().ToString());

            Program.frmMainForm.delAddClient.Invoke(client);

            ClientConnection objClientConnection = new ClientConnection(client);
            objClientConnection.OnMessageReceived += new MessageReceive(OnReceive);
            objClientConnection.OnRemoteHostClosed += new RemoteHostClose(OnRemoteHostClose);
        }
开发者ID:zhushipeng,项目名称:hightone,代码行数:11,代码来源:ListenerHelper.cs

示例4: SMTPRelayer

        public SMTPRelayer(TcpClient tcpClient, SMTPSettings settings)
        {
            this.settings = settings;
            Console.WriteLine("Connected... {0}", tcpClient.GetHashCode());

            this.client_tcp = tcpClient;
            this.client_Stream = tcpClient.GetStream();

            this.server_tcp = new TcpClient(settings.RemoteAddress, settings.RemotePort);
            this.server_Stream = server_tcp.GetStream();

            this.readthread = new Thread(new ThreadStart(Read));
            this.writethread = new Thread(new ThreadStart(Write));
        }
开发者ID:aont,项目名称:SMTPHacker,代码行数:14,代码来源:SMTPRelayer.cs

示例5: Connection

        public Connection(TcpClient client, Player player)
        {
            _Client = client;
            IPString = _Client.Client.RemoteEndPoint.ToString();

            _Running = true;
            _TransmitQueue = new Queue<byte[]>();
            _Buffer = new byte[0];
            _Player = player;

            _Thread = new Thread(ConnectionThread);
            _Thread.Name = "SC-Player " + _Client.GetHashCode();
            _Thread.Start();
        }
开发者ID:24500,项目名称:Spacecraft-GT,代码行数:14,代码来源:Connection.cs

示例6: AddClient

        private void AddClient(TcpClient client)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new AddClientDelegate(AddClient), client);
            }
            else
            {
                ClientInfo info = new ClientInfo();
                info.ClientHost = client.GetHashCode().ToString();
                info.ConnectTime = DateTime.Now;

                lstClientInfo.Add(info);
                lstTcpClient.Add(client);

                bindingSource1.DataSource = lstClientInfo.ToArray();
                bindingSource1.Sort = "ConnectTime";

                LogHelper.ShowLog("Add Client\t" + info.ClientHost +
                    "\t Client List count:" + lstTcpClient.Count.ToString());
            }
        }
开发者ID:zhushipeng,项目名称:hightone,代码行数:22,代码来源:MainForm.cs

示例7: RemoveClient

        private void RemoveClient(TcpClient client)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new RemoveClientDelegate(RemoveClient), client);
            }
            else
            {
                for (int i = 0; i < lstClientInfo.Count; i++)
                {
                    if (lstClientInfo[i].ClientHost == client.GetHashCode().ToString())
                    {
                        lstTcpClient.Remove(client);
                        lstClientInfo.RemoveAt(i);
                        break;
                    }
                }

                if (lstClientInfo.Count < 1)
                {
                    bindingSource1.Clear();
                }
                else
                {
                    bindingSource1.Clear();
                    bindingSource1.DataSource = lstClientInfo;
                }

                LogHelper.ShowLog("Remove Client\t" + client.GetHashCode().ToString() +
                    "\t Client List count:" + lstTcpClient.Count.ToString());
            }
        }
开发者ID:zhushipeng,项目名称:hightone,代码行数:32,代码来源:MainForm.cs

示例8: BeginSend

		public IAsyncResult BeginSend(string host, int port, bool useTls, string callingAe, string calledAe, AsyncCallback callback, object state) {
			_client = new TcpClient(host, port);
            //zssure:2015-04-14,try to conform whether AddRequest and Send uses the same one client
            LogManager.Default.GetLogger("Dicom.Network").Info("zssure debug at 20150414,the TcpClient object is {0},HashCode{1}", _client.ToString(),_client.GetHashCode()); 
            //zssure:2015-04-14,end

			if (Options != null)
				_client.NoDelay = Options.TcpNoDelay;
			else
				_client.NoDelay = DicomServiceOptions.Default.TcpNoDelay;

			Stream stream = _client.GetStream();

			if (useTls) {
				var ssl = new SslStream(stream, false, ValidateServerCertificate);
				ssl.AuthenticateAsClient(host);
				stream = ssl;
			}

			return BeginSend(stream, callingAe, calledAe, callback, state);
		}
开发者ID:ZeryZhang,项目名称:fo-dicom,代码行数:21,代码来源:DicomClient.cs

示例9: ConnectSocket

        public static bool ConnectSocket(
           ref TcpClient client,
           string remoteHost,
           int remotePort,
            AsyncCallback asyncCallback)
        {
            try
            {
                #region main process

                if (client == null || client.Client == null)
                {
                    client = new TcpClient();
                }

                if (client.Connected)
                {
                    LogHelper.ShowLog("Re-Connect\t" + DateTime.Now.ToString() + "\t" +
                        "close current connect\t" + client.GetHashCode().ToString());

                    if (client.GetStream() != null)
                    {
                        client.GetStream().Close();
                    }

                    client.Close();
                    client = new TcpClient();

                    LogHelper.ShowLog("Create Client\t" + DateTime.Now.ToString() + "\t" +
                        client.GetHashCode().ToString());
                }

                try
                {
                    client.Connect(remoteHost, remotePort);
                }
                catch (ObjectDisposedException)
                {
                    client = new TcpClient();
                    client.Connect(remoteHost, remotePort);

                    LogHelper.ShowLog("Create Client\t" + DateTime.Now.ToString() + "\t" +
                        client.GetHashCode().ToString());
                }

                client.GetStream().BeginRead(readBuffer, 0,
                    READ_BUFFER_SIZE, asyncCallback, client);

                #endregion

                return true;
            }
            catch (SocketException ex)
            {
                if (client != null)
                {
                    client.Close();
                }

                ExceptionHelper.ShowException(ex);
            }
            catch (Exception ex)
            {
                if (client != null)
                {
                    client.Close();
                }

                ExceptionHelper.ShowException(ex);
            }

            return false;
        }
开发者ID:zhushipeng,项目名称:hightone,代码行数:73,代码来源:ClientHelper.cs

示例10: HandleReceive

 public static void HandleReceive(TcpClient client, string data)
 {
     LogHelper.ShowLog("Receive\t\t" + DateTime.Now.ToString() + "\t" +
         client.GetHashCode().ToString() + "\t" + data);
 }
开发者ID:zhushipeng,项目名称:hightone,代码行数:5,代码来源:ClientHelper.cs


注:本文中的System.Net.Sockets.TcpClient.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。