tcp client --test
时间:2006-07-08 来源:nemanman
#!/usr/bin/env python
# -*-coding:UTF-8 -*-
import socket
import time
import re
import sys
SERVER='127.0.0.1'
PORT=8888
c=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
c.connect((SERVER,PORT))
except:
sys.exit("连接服务器失败")
while True:
sstr=raw_input("what do you send:")
c.send(sstr)
if sstr=="/quit":
c.close()
break
# -*-coding:UTF-8 -*-
import socket
import time
import re
import sys
SERVER='127.0.0.1'
PORT=8888
c=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
c.connect((SERVER,PORT))
except:
sys.exit("连接服务器失败")
while True:
sstr=raw_input("what do you send:")
c.send(sstr)
if sstr=="/quit":
c.close()
break
相关阅读 更多 +