python内网即时通信小程序

2023-01-31 05:01:00 程序 内网 即时通信

环境: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()

相关文章