0

I am getting this error when I run this program. I am new to socket programming so I am not sure what this error is.

If SOme could provide an explenation and a solution it would be great

line 23, in message, address = clientSocket.recvfrom(1024) error: [Errno 10054] An existing connection was forcibly closed by the remote host

 from socket import *

import time

print ("Running")

serverName = '127.0.0.1' 

clientSocket = socket(AF_INET,SOCK_DGRAM) 

clientSocket.settimeout(1) 

sequence_number = 1 

while sequence_number<=10:
    message = "Ping" 

    start=time.time() 

    clientSocket.sendto(message.encode(),(serverName, 8000))
try:

    message, address = clientSocket.recvfrom(1024) 
    elapsed = (time.time()-start)
    print (sequence_number)

    print (message)

    print ("Round Trip Time is:" + str(elapsed) +  "seconds" )

except timeout: 

    print (sequence_number)

    print ("Request timed out")

sequence_number+=1 

if sequence_number > 10: 
    clientSocket.close()
joe
  • 39
  • 6
  • Its is an assigment I had to do. I have to ping a server 10 times and give various information. – joe Oct 23 '15 at 20:44
  • Possible duplicate of [Python socket error on UDP data receive. (10054)](http://stackoverflow.com/questions/2576926/python-socket-error-on-udp-data-receive-10054) – tintin Oct 23 '15 at 20:44
  • http://stackoverflow.com/questions/316866/ping-a-site-in-python – Swastik Padhi Oct 23 '15 at 20:46

0 Answers0