server:
[root@localhost /]# cat server.py
#!/bin/python
import socket
ser=socket.socket()
hostname=socket.gethostname()
port=1234
A=hostname,port
ser.bind(A)
ser.listen(5)
while 1:
cli,addr=ser.accept()
print addr
cli.send('hahhahahahahahha')
str=cli.recv(30)
print str
cli.close()
[root@localhost /]#
client:
[root@localhost /]# cat client.py
#!/bin/python
import socket
cli=socket.socket()
hostname=socket.gethostname()
port=1234
B=hostname,port
cli.connect(B)
str=cli.recv(10)
cli.send('cliclicliclicli')
print str
cli.close()
[root@localhost /]#
阅读(18333) | 评论(0) | 转发(0) |