0

UDP client not returning any data

I am learning how to create a basic udp client with python. The problem is that the data variable is not returning any data. The screen remains blank once the script attempts to "print (data)". import socket target_host = "127.0.0.1" target_port = 80 client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) print ("sending data") client.sendto(b"AAABBBCCC", (target_host, target_port)) print ("data sent") print ("recieving data") data, addr = client.recvfrom(4096) print ("data recieved") print (data) Any ideas on why?

30th Jun 2018, 10:09 AM
Kyle Matthew Ford
Kyle Matthew Ford - avatar
5 Answers
+ 1
Kyle Matthew Ford Could you post also the server code?
30th Jun 2018, 10:47 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
Kyle Matthew Ford I believe that, that's the problem.
30th Jun 2018, 11:05 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
I'll create the server script and return if the problem persists
30th Jun 2018, 11:06 AM
Kyle Matthew Ford
Kyle Matthew Ford - avatar
0
there is no server yet. This client script is all i've done so far. could that be the problem?
30th Jun 2018, 11:03 AM
Kyle Matthew Ford
Kyle Matthew Ford - avatar
0
Ulisses Cruz Would I be able to connect a UDP client to a TCP server? Or does my client have to also be TCP?
30th Jun 2018, 11:22 AM
Kyle Matthew Ford
Kyle Matthew Ford - avatar