Namespace microshaoft {using system; using system. text; using system. net; using system. net. sockets; using system. servicemodel. channels; Class echoserver {socket server; Public echoserver (ipendpoint localpoint) {Server = new socket (localpoint. addressfamily, sockettype. stream, protocoltype. TCP); server. BIND (localpoint); server. listen (5); accept_async ();} private void accept_async () {var acce PT = new socketasynceventargs (); accept. completed + = accept_completed; server. acceptasync (accept);} int I = 0; void accept_completed (Object sender, socketasynceventargs e) {accept_async (); var client = E. acceptsocket; E. usertoken = I ++; E. completed-= accept_completed; E. completed + = receive_completed; var buffer = new byte [1024]; E. setbuffer (buffer, 0, buffer. length); client. receiveasync (E );} Void receive_completed (Object sender, socketasynceventargs e) {var client = sender as socket; If (E. bytestransferred = 0) {console. writeline ("socket is closed"); client. close ();} else {// client. send (E. buffer, E. bytestransferred, socketflags. none); byte [] buffer = new byte [E. bytestransferred]; buffer. blockcopy (E. buffer, 0, buffer, 0, buffer. length); string S = bitconverter. tostring (buffer );/ /S = encoding. ASCII. getstring (buffer); console. writeline ("==={ 0} usertoken: [{1}] {0} bytes transferred: [{2}] {0} data: [{3}] {0 }=== "," \ r \ n ", E. usertoken, E. bytestransferred, S); // console. writeline (s); client. receiveasync (e) ;}}} namespace consoleapplication {using system; using system. net; using microshaoft; // <summary> /// Summary of class1. /// </Summary> public class class1 {// <summary> // ApplicationProgram . /// </Summary> // [stathread] Static void main (string [] ARGs) {// todo: add Code To start the application // IPaddress IPA; IPaddress. tryparse ("127.0.0.1", out IPA); echoserver x = new echoserver (New ipendpoint (IPA, 8180); console. writeline ("Hello World"); console. writeline (environment. version. tostring (); console. readline ();}}}