在python 2.7上获得错误10053

时间:2016-11-10 14:17:55

标签: python

我启动网络并且我的代码不是最好的但是出于某种原因我不明白当我运行我的客户端时我得到错误10053

import socket 
import datatime
import random
s_server = socket.socket()
s_server.bind(('127.0.0.1', 44444))
s_server.listen(1)
print "waiting"
(c_socket, c_address) = s_server.accept()
print "connected"
c_receive = c_socket.recv(1024)
time = datetime.datetime.now()
if c_receive == "time":
   c_socket.send(time)
if c_receive == "name":
    c_socket.send("server name is kingsfall")
random1 = random.random[1.0, 10.0]
if c_receive == "random":
    c_socket.send(random1)
if c_receive == "close":
    s_server.close()
    c_socket.close()

这是客户端

import socket
c_socket = socket.socket()
c_socket.connect(('127.0.0.1', 44444))
c_socket.send("time")
print c_socket.recv(1024)
c_socket.send("random")
print c_socket.recv(1024)
c_socket.send("name")
print c_socket.recv(1024)
c_socket.send("quit")
c_socket.close()

这是错误

  

第7行,

     

print c_socket.recv(1024)

     

socket.error:[Errno 10053]已建立的连接已被主机中的软件中止

0 个答案:

没有答案