1

I'm starting networks and my code isn't the best but for some reason I don't understand why I'm getting error 10053 when I'm running my client.

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()

This is the client:

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()

This is the error:

line 7, in <module>
print c_socket.recv(1024)
socket.error: [Errno 10053] An established connection was aborted by the software in your host machine 
colidyre
  • 4,170
  • 12
  • 37
  • 53
  • 3
    Possible duplicate of [error: \[Errno 10053\]](http://stackoverflow.com/questions/17854713/error-errno-10053) – depperm Nov 10 '16 at 14:20
  • and for some reason the var time doesnt have the time but has the datatime.datatime command inside of it – Yona Haim Burman Nov 10 '16 at 14:23
  • You should add exception handling to most of these function calls, also helps your program from crashing. and you should try adding a wait or sleep function call before your print c_socket.recv(1024) and see if it works. – Omid CompSCI Nov 24 '16 at 18:44

0 Answers0