Python Socket Instance Practice

Source: Internet
Author: User

Simple socket Communication

Server

Import socketsock_server = Socket.socket (socket.af_inet, socket. SOCK_STREAM) sock_server.setsockopt (socket. Sol_socket, SOCKET. SO_REUSEADDR, 1)  # Reuse Address Port Sock_server.bind ((' 127.0.0.1 ', 8088)) Sock_server.listen (1)  # Start listening, 1 stands for a connection in the Allow queue, More new connections will be rejected print (' starting ... ') while True:    conn, client_addr = Sock_server.accept ()  # blocks until a connection is reached. When a new connection comes in, a connection object is generated for this request    print (CLIENT_ADDR) while    True:        try:            data = CONN.RECV (1024) # receives 1024 bytes            if not Data:break  # applies to the Linux operating system, prevents the client from disconnecting after the dead loop            print (' Client's data ', ' Conn.sendall ')            (Data.upper ())  # Return all received data back to the client        except Connectionreseterror:  # for Windows operating systems, prevent clients from disconnecting after a dead loop break    Conn.close () Server.close ()

Client

Import socketclient = Socket.socket (socket.af_inet, socket. SOCK_STREAM) print (client) client.connect ((' 127.0.0.1 ', 8088)) while True:    data = input (' input >>> ')    If not data:  # to continue entering        continue    client.send (Data.encode (' Utf-8 ')) # if it is empty #  send data    = CLIENT.RECV ( 1024x768)   # receive data    print (' receive data = ', Data.decode ()) Client.close ()  # Close

Server output

Starting ... (' 127.0.0.1 ', 4612) client data b ' HELLP ' client data b ' Java ' (' 127.0.0.1 ', 4618) client data b ' ABC ' Client data B ' CD '

CLIENT1 output

<socket.socket fd=216, Family=addressfamily.af_inet, Type=socketkind.sock_stream, Proto=0>input >>> HELLP Receive data = Hellpinput >>>java receive data = Javainput >>>process finished with exit Code-1 # Close CLIENT1

CLIENT2 output

<socket.socket fd=216, Family=addressfamily.af_inet, Type=socketkind.sock_stream, Proto=0>input >>> ABC Receive data = Abcinput >>>CD receive data = CDinput >>>
Impersonation SSH Remote execution command

Sever End

Import socketimport subprocessdef cmd_exec (cmd): "" "Executes shell command:p Aram CMD:: Return:" "" P = SUBPROCESS.P Open (cmd, shell=true, stdin=subprocess. Pipe,stdout=subprocess. Pipe,stderr=subprocess. PIPE) stdout, stderr = P.communicate () if p.returncode! = 0:return stderr return stdoutsock_server = sock Et.socket (socket.af_inet, socket. SOCK_STREAM) sock_server.setsockopt (socket. Sol_socket, SOCKET. SO_REUSEADDR, 1) # Reuse address Port Sock_server.bind ((' 127.0.0.1 ', 8088)) Sock_server.listen (1) # Start listening, 1 stands for a connection in the Allow queue, More new connections will be rejected when the print (' starting ... ') while true:conn, client_addr = Sock_server.accept () # is blocked until a connection is made, and a new connection comes in.  To survive as a Connection object print (client_addr) while True:try:data = CONN.RECV (1024) # receive 1024 bytes if not Data:break # for Linux operating system, prevent client disconnects after dead loop print (' Client command ', Data.decode (' GBK ')) res = Cmd_exec (DATA.D        Ecode (' GBK ') # Execute CMD command print (RES) Conn.sendall (RES) # return all incoming data to the clientExcept Connectionreseterror: # applies to Windows operating systems, prevents clients from disconnecting after a dead loop break Conn.close () Server.close () 

Client Side

Import socketclient = Socket.socket (socket.af_inet, socket. SOCK_STREAM) print (client) client.connect ((' 127.0.0.1 ', 8088)) while True:    data = input (' input >>> ')    If not data:  # to continue entering        continue    client.send (Data.encode (' GBK '))  # send data    response = bytes () If it is empty Data    = CLIENT.RECV (1024x768)   # receives the    print (' receive data = ', Data.decode (' GBK ', ' ignore '))  # If set to ignore, illegal characters are ignored; Client.close ()  # Close

Server output

 

starting ... ('127.0.0.1', 6091) The client's command ipconfig/ All7705 b'\r\nwindows IP \xc5\xe4\xd6\xc3\r\n\r\n \XD6\XF7\XBB\XFA\XC3\XFB ............. : jingjing-pc\r\n \xd6\xf7 DNS \xba\xf3\xd7\xba ........... : \ r \ n \xbd\xda\xb5\xe3\xc0\xe0\xd0\xcd ...: \xbb\xec\xba\xcf\r\n IP \xc2\xb7\xd3\xc9\xd2\xd1\xc 6\xf4\xd3\xc3: \xb7\xf1\r\n WINS \xb4\xfa\xc0\xed\xd2\xd1\xc6\xf4\xd3\xc3 ........... . : \xb7\xf1\r\n\r\n\xd2\xd4\xcc\xab\xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 \xb1\xbe\xb5\xd8\xc1\xac\xbd\xd3 3:\r\n\r\n \ Xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ...: \xc3\xbd\xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd, ..... \xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf6. .............. : Bluetooth PAN Network adapter\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 60-f8-1d-ad-89-ef\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xca\xc7\r\n \XD7\XD4\XB6\XAF\XC5\XE4\XD6\XC3\XD2\XD1\XC6\XF4\XD3\XC3 ..... . : \xca\xc7\r\n\r\n\xce\xde\xcf\xdf\xbe\xd6\xd3\xf2\xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 \xce\xde\xcf\xdf\xcd\xf8\xc2\ xe7\xc1\xac\xbd\xd3:\r\n\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\ Xe8\xca\xf6. .............. : Broadcom 802.11ac Network adapter\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 60-f8-1d-ad-89-ee\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xca\xc7\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3 ....: \xca\xc7\r\n \xb1\xbe\ Xb5\xd8\xc1\xb4\xbd\xd3 IPv6 \xb5\xd8\xd6\xb7 ... : fe80::55d1:e185:f929:8ce3%13 (\XCA\XD7\XD1\XA1) \ r \ IPv4 \xb5\xd8\xd6\xb7 ............:192.168.31.125(\ XCA\XD7\XD1\XA1) \ r \ n \xd7\xd3\xcd\xf8\xd1\xda\xc2\xeb ...: 255.255.255.0\r\n \xbb\xf1\xb5\xc3\x D7\xe2\xd4\xbc\xb5\xc4\xca\xb1\xbc\xe4 ..... .  : 2018\xc4\xea7\xd4\xc25\xc8\xd5 20:46:29\r\n \xd7\xe2\xd4\xbc\xb9\xfd\xc6\xda\xb5\xc4\xca\xb1\xbc\xe4 ..... . : 2018\xc4\xea7\xd4\xc26\xc8\xd5 8:46:29\r\n \xc4\xac\xc8\xcf\xcd\xf8\xb9\xd8. ............ : 192.168.31.1\r\n DHCP \xb7\xfe\xce\xf1\xc6\xf7 ........... : 192.168.31.1\r\n DHCPv6 IAID ........... : 291567645\r\n DHCPv6 \xbf\xcd\xbb\xa7\xb6\xcb DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee\r\n DN S \xb7\xfe\xce\xf1\xc6\xf7 ........... : 114.114.114.114\r\n TCPIP \xc9\xcf\xb5\xc4 NetBIOS .......:\xd2\xd1\xc6\xf4\xd3\xc3\r\n\r\n\xd2\xd4\xcc\xab \xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 VirtualBox host-only network:\r\n\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf6. .............. : VirtualBox host-only Ethernet adapter\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 0a-00-27-00-00-13\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\ n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3 ...: \xca\xc7\r\n \xb1\xbe\xb5\xd8\xc1\ Xb4\xbd\xd3 IPv6 \xb5\xd8\xd6\xb7 ...  : fe80::7d26:2c96:84f1:6c4d%19 (\XCA\XD7\XD1\XA1) \ r \ \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3 IPv4 \xb5\xd8\xd6\xb7 ...: 169.254.108.77 (\xca\xd7\xd1\xa1) \ r \ n \xd7\xd3\xcd\xf8\xd1\xda\xc2\xeb ............:255.2 55.0.0\r\n \xc4\xac\xc8\xcf\xcd\xf8\xb9\xd8. ............ : 192.168.56.255\r\n DHCPv6 IAID ........... : 336199719\r\n DHCPv6 \xbf\xcd\xbb\xa7\xb6\xcb DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee\r\n DN S \xb7\xfe\xce\xf1\xc6\xf7 ...........                                       : fec0:0:0:ffff::1%1\r\n fec0:0:0:ffff::2%1\r\n fec0:0:0:ffff::3%1\r\n TCPIP \xc9\xcf\xb5\xc4 NetBIOS .......:\xd2\xd1\xc6\xf4\xd3\xc3\r\n\r\n\xd2\xd4\xcc\x Ab\xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 VirtualBox host-onlyNetwork #2: \r\n\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf  6 .....: VirtualBox host-only Ethernet Adapter #2 \ r \ n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7 ..... . . . . . . . . : 0a-00-27-00-00-14\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3 ....: \xca\xc7\r\n \xb1\xbe\ Xb5\xd8\xc1\xb4\xbd\xd3 IPv6 \xb5\xd8\xd6\xb7 ... : fe80::641c:b67e:fa43:a28d%20 (\XCA\XD7\XD1\XA1) \ r \ IPv4 \xb5\xd8\xd6\xb7 ............:192.168.96.1(\ XCA\XD7\XD1\XA1) \ r \ n \xd7\xd3\xcd\xf8\xd1\xda\xc2\xeb ...: 255.255.255.0\r\n \xc4\xac\xc8\xcf\x Cd\xf8\xb9\xd8. ............ : \ r \ DHCPv6 IAID ........... : 537526311\r\n DHCPv6 \xbf\xcd\xbb\xa7\xb6\xcb DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee\r\n DN S \xb7\xfe\xce\xf1\xc6\xf7 ..... . . . . . .                                       : fec0:0:0:ffff::1%1\r\n fec0:0:0:ffff::2%1\r\n fec0:0:0:ffff::3%1\r\n TCPIP \xc9\xcf\xb5\xc4 NetBIOS .......:\xd2\xd1\xc6\xf4\xd3\xc3\r\n\r\n\xd2\xd4\xcc\x Ab\xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 VMware Network Adapter vmnet1:\r\n\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ....: \ r \ n \xc3\xe8\xca\xf6. .............. : VMware Virtual Ethernet Adapter for vmnet1\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-50-56-c0-00-01\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xca\xc7\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3 ....: \xca\xc7\r\n \xb1\xbe\ Xb5\xd8\xc1\xb4\xbd\xd3 IPv6 \xb5\xd8\xd6\xb7 ... : fe80::20c1:b2f0:8bff:626c%25 (\XCA\XD7\XD1\XA1) \ r \ IPv4 \xb5\xd8\xd6\xb7 ............:192.168.109.1(\ XCA\XD7\XD1\XA1) \ r \ \XD7\XD3\XCD\XF8\XD1\XDA\XC2\xeb ...: 255.255.255.0\r\n \xbb\xf1\xb5\xc3\xd7\xe2\xd4\xbc\xb5\xc4\xca\xb1\xbc\xe4 ......... . . . .  : 2018\xc4\xea7\xd4\xc25\xc8\xd5 20:46:20\r\n \xd7\xe2\xd4\xbc\xb9\xfd\xc6\xda\xb5\xc4\xca\xb1\xbc\xe4 . . . . . . . . . : 2018\xc4\xea7\xd4\xc25\xc8\xd5 23:46:20\r\n \xc4\xac\xc8\xcf\xcd\xf8\xb9\xd8. ............ : \ r \ n DHCP \xb7\xfe\xce\xf1\xc6\xf7 ........... : 192.168.109.254\r\n DHCPv6 IAID ........... : 385896534\r\n DHCPv6 \xbf\xcd\xbb\xa7\xb6\xcb DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee\r\n DN S \xb7\xfe\xce\xf1\xc6\xf7 ...........                                       : fec0:0:0:ffff::1%1\r\n fec0:0:0:ffff::2%1\r\n fec0:0:0:ffff::3%1\r\n TCPIP \xc9\xcf\xb5\xc4 NetBIOS .......:\xd2\xd1\xc6\xf4\xd3\xc3\r\n\r\n\xd2\xd4\xcc\x Ab\xcd\xf8\xca\xca\xc5\xe4\xc6\xf7 VMware Network Adapter vmnet8:\r\n\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf6. .............. : VMware Virtual Ethernet Adapter for vmnet8\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-50-56-c0-00-08\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xca\xc7\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3 ....: \xca\xc7\r\n \xb1\xbe\ Xb5\xd8\xc1\xb4\xbd\xd3 IPv6 \xb5\xd8\xd6\xb7 ... : fe80::61fd:5f66:1f70:cb3d%26 (\XCA\XD7\XD1\XA1) \ r \ IPv4 \xb5\xd8\xd6\xb7 ............:192.168.5.1(\XCA \XD7\XD1\XA1) \ r \ n \xd7\xd3\xcd\xf8\xd1\xda\xc2\xeb ...: 255.255.255.0\r\n \xbb\xf1\xb5\xc3\xd7\ Xe2\xd4\xbc\xb5\xc4\xca\xb1\xbc\xe4 ..... .  : 2018\xc4\xea7\xd4\xc25\xc8\xd5 20:46:21\r\n \xd7\xe2\xd4\xbc\xb9\xfd\xc6\xda\xb5\xc4\xca\xb1\xbc\xe4 . . . . . . . . . : 2018\xc4\xea7\xd4\xc25\xc8\xd5 23:46:21\r\n \xc4\xac\xc8\xcf\xcd\xf8\xb9\xd8. ............ : \ r \ n   DHCP \xb7\xfe\xce\xf1\xc6\xf7 ........... : 192.168.5.254\r\n DHCPv6 IAID ........... : 402673750\r\n DHCPv6 \xbf\xcd\xbb\xa7\xb6\xcb DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee\r\n DN S \xb7\xfe\xce\xf1\xc6\xf7 ...........                                       : fec0:0:0:ffff::1%1\r\n fec0:0:0:ffff::2%1\r\n fec0:0:0:ffff::3%1\r\n \xd6\xf7 WINS \xb7\xfe\xce\xf1\xc6\xf7 ... . : 192.168.5.2\r\n TCPIP \xc9\xcf\xb5\xc4 NetBIOS .......:\xd2\xd1\xc6\xf4\xd3\xc3\r\n\r\n\xcb\xed\xb5\xc0\xca \xca\xc5\xe4\xc6\xf7 \xb1\xbe\xb5\xd8\xc1\xac\xbd\xd3* 14:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ... . . . . : \xc3\xbd\xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba .....: \ r \ n \xc3\xe8\xca\xf6. .............. : Microsoft ISATAP Adapter #2 \ r \ n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7 ..... .....: 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3. .........:\xca\xc7\r\n\r\n\xcb\  Xed\xb5\xc0\xca\xca\xc5\xe4\xc6\xf7 Teredo tunneling pseudo-interface:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ......: \xc3\xbd\xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf6. .............. : Teredo tunneling pseudo-interface\r\n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3. .........:\xca\xc7\r\n\r\n\xcb\ Xed\xb5\xc0\xca\xca\xc5\xe4\xc6\xf7 ISATAP. {0da4a980-7247-4922-aafb-55760b865c15}:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ............:\xc3\xbd \xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\x E8\xca\xf6. .............. : Microsoft ISATAP Adapter #3 \ r \ \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3. .........:\xca\xc7\r\n\r\n\xcb\ Xed\xb5\xc0\xca\xca\xc5\xe4\xc6\xf7 isatap.localdomain:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ... .....: \xc3\xbd\xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\ Xba ...: \ r \ n \xc3\xe8\xca\xf6. .............. : Microsoft ISATAP Adapter #5 \ r \ \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xF4\xd3\xc3 ....: \xca\xc7\r\n\r\n\xcb\xed\xb5\xc0\xca\xca\xc5\xe4\xc6\xf7 \xb1\xbe\xb5\xd8\xc1\xac\. xbd\xd3* 15:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ............:\XC3\XBD\XCC\XE5\XD2\XD1\XB6\XCF\XBF  \xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r \ n \xc3\xe8\xca\xf6 ..... .....: Microsoft ISATAP Adapter #6 \ r \ n \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3. .........:\xca\xc7\r\n\r\n\xcb\ Xed\xb5\xc0\xca\xca\xc5\xe4\xc6\xf7 ISATAP. {94c5f926-3e20-4589-a88e-54a36934d42c}:\r\n\r\n \xc3\xbd\xcc\xe5\xd7\xb4\xcc\xac ............:\xc3\xbd \xcc\xe5\xd2\xd1\xb6\xcf\xbf\xaa\r\n \xc1\xac\xbd\xd3\xcc\xd8\xb6\xa8\xb5\xc4 DNS \xba\xf3\xd7\xba ...: \ r\n \xc3\xe8\xca\xf6. ..............: Microsoft ISATAP Adapter #8 \ r \ \xce\xef\xc0\xed\xb5\xd8\xd6\xb7. ............ : 00-00-00-00-00-00-00-e0\r\n DHCP \xd2\xd1\xc6\xf4\xd3\xc3 ........... : \xb7\xf1\r\n \xd7\xd4\xb6\xaf\xc5\xe4\xd6\xc3\xd2\xd1\xc6\xf4\xd3\xc3. .........:\xca\xc7\r\n'command for the client LSb"' ls ' \xb2\xbb\xca\xc7\xc4\xda\xb2\xbf\xbb\xf2\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\xa3\xac\xd2\xb2\xb2\xbb\xca\ Xc7\xbf\xc9\xd4\xcb\xd0\xd0\xb5\xc4\xb3\xcc\xd0\xf2\r\n\xbb\xf2\xc5\xfa\xb4\xa6\xc0\xed\xce\xc4\xbc\xfe\xa1\ xa3\r\n"

  

Client output

Input >>>ipconfig/all Receive data = Windows IP Configuration host name ............. :-pc primary DNS suffix ........... : node type ............: hybrid IP routing enabled ..........: no WINS agent enabled ... . : No Ethernet Adapter Local Area Connection 3: Media status ............: media disconnected specific DNS suffix ...: Description .............. . : Bluetooth PAN Network Adapter Physical Address ............. : 60-f8-1d-ad-89-ef DHCP is enabled ........... : Is automatic configuration enabled ..........: is a wireless LAN adapter wireless network connection: Connection specific DNS suffix ...: description ............... : Broadcom 802.11ac Network Adapter Physical Address ............. : 60-f8-1d-ad-89-ee DHCP is enabled ........... : Is automatic configuration enabled ..........: is a local link IPv6 address ..... : fe80::55d1:e185:f929:8ce3%13 (preferred) IPV4 address ............:192.168.31.125(preferred) Subnet mask input &GT;&GT;&GT;LS receive data =............:255.255.255.0 time to obtain a lease ... . : July 5, 2018 20:46:29 the lease expiresTime........ . : July 6, 2018 8:46:29 default gateway ............. : 192.168.31.1 DHCP Server ........... : 192.168.31.1 DHCPv6 IAID ...........  : 291567645 DHCPv6 Client DUID ...: 00-01-00-01-21-7c-0d-6e-60-f8-1d-ad-89-ee DNS server ...........  : 114.114.114.114 TCPIP on NetBIOS ...: Enabled Ethernet Adapter VirtualBox host-only Network: Connection-specific DNS suffix .... . : Description ............... : VirtualBox host-only Ethernet Adapter Physical Address ............. : 0a-00-27-00-00-13 DHCP is enabled ........... : No automatic configuration Enabled ..........: is a local link IPv6 address ..... : fe80::7d26:2c96:84f1:6c4d%19 (preferred) automatically configures IPV4 address .......:169.254.108.77(preferred) Subnet mask ............: 255.255.0.0 the default gateway. .  Input >>>#出现粘包现象

  

  

Python Socket Instance Practice

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.