python内网即时通信小程序
环境:kali 一个server.py和client.py
sever.py# -*- coding: utf-8 -*
#Server.py
import Socket
host = socket.gethostname()
port = 12345
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(1)
sock, addr = s.accept()
print "Linked"
info = sock.recv(1024)
while info != "exit":
print "From Others : "+info
send_mes = raw_input("")
sock.send(send_mes)
if send_mes == "exit":
break
info = sock.recv(1024)
sock.close()
s.close()
相关文章