所以我试图在我的客户和Espec环境商会之间建立联系。当我向房间发送命令时,我得不到任何数据作为回报。有谁知道这是什么问题?
import socket
from sys import argv, exit
ip = argv[1]
port = int(argv[2])
x = argv[3]
try:
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error, e:
print "Error creating socket:: %s" % e
exit(1)
try:
c.connect((ip, port))
except socket.error, e:
print "Connection error: %s" % e
exit(1)
try:
c.send(x)
except socket.error, e:
print "Error sending data: %s" %e
exit(1)
c.settimeout(10.0)
while True:
try:
buff = str(c.recv(4096))
except socket.error, e:
print "Error receiving data: %s" % e
exit(1)
if not len(buff):
break
print buff
exit(1)