When using TCPListener's Acceptsocket () method and accepttcpclient () method, the program always seems to be like a dead!

xiaoxiao2021-03-06  40

Why do I always seem to be alcohol when using the TCPListener's Acceptsocket () method to accept remote data. When the debugging is not moved on the Acceptsocket () method or the accepttcpclient () method, and the data read will continue to execute. What should I do if I solve this crash? Thanks specific code as follows: /AcceptSocketThread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; tcpl = new TcpListener (IPAddress.Parse ( "172.18.12.34"), 8000); // tcpl.Start listens on port 8000 (); IF (! tcpl.pending ()) {thread.sleep (200); socket s = tcpl.acceptsocket (); thread.sleep (200);} /// acceptttcpclientInt32 port = 8000; tcplistener server = new TCPListener (iPaddress. PARSE ("172.18.12.34"), port); server.Start (); byte [] bytes = new byte [36]; string data = null; bool a = true; while (a) {tcpclient client = server.accepttcpclient (); Data = NULL; NetworkStream Stream = client.getStream (); int32 i; while ((i = stream.read (bytes, 0, bytes.length))! = 0) {data = system.text.Encoding. Ascii.getstring (bytes, 0, i);}}

转载请注明原文地址:https://www.9cbs.com/read-86276.html

New Post(0)