0

I am establishing a TFTP connection using UDP. My client is able to successfully send a request to server

    cSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    cSocket.bind(('', clientPort))
    cSocket.settimeout(1)
    cSocket.sendto(key, (Serverip, 69)) 

And server is able to receive it

    serverSock.bind((serverIP, 69))
    request, clientIP = serverSock.recvfrom(1024)

Now from anthother port server is responding back to client with an acknowledgement

    aSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    aSocket.settimeout(0.1)
    aSocket.sendto(byteArray, (clientIP, clientPort))

From Wireshark I am able to see the acknoledgement send from server but

data, addr = cSocket.recvfrom(1024)

Leads to a timeout exception. Where did i went wrong?

Hari Krishnan
  • 5,992
  • 9
  • 37
  • 55
  • Does traffic to the client pass through a firewall? If so, then since the response is from a different port (and perhaps a different IP) than the target of the request, it would likely be blocked. – ottomeister Dec 31 '19 at 01:33
  • I connected two PCs directly with a lan. And the response is not coming from a different IP. port is different. If it is blocked, can it be loged in wireshark? Then how it could be accessed within the script? – Hari Krishnan Dec 31 '19 at 05:08
  • PCs can have internal firewalls. For example, Windows has one that is enabled by default. If your client is on Windows then you could temporarily disable the firewall and see if that helps. Or you could send responses through `serverSocket` so that they come from port 69; by default the Windows firewall will allow responses from the destinations of outbound datagrams for a short period. On Windows, Wireshark sees packets before they reach the firewall. If you see responses in Wireshark on the client but your program doesn't get them, that makes the firewall a likely cause. – ottomeister Dec 31 '19 at 17:46

0 Answers0