"An integer is required error received for UDP server"

Viewed 43

I try to communicate 2 raspberry pi's and I use UDP server. While creating udp server I used the codes below, however I took an error as it requires an integer at the line 10. Can you help me please ?

This is for Raspberry pi 3 and I try udp server.

import socket

UDP_IP = "127.0.0.1"
UDP_PORT = "5005"
MESSAGE ="1"
print "UDP target IP:", UDP_IP
print " UDP target port:", UDP_PORT
print"message:", MESSAGE
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

I expect to create the sending server.

1 Answers

welcome to StackOverflow! I solved this by changing UDP_PORT to 5005 instead of "5005".

#/usr/bin/python
import socket

UDP_IP = "127.0.0.1"
UDP_PORT = 5005
MESSAGE ="1"
print "UDP target IP:", UDP_IP
print " UDP target port:", UDP_PORT
print"message:", MESSAGE
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

It's asking for an integer and interpreting your argument "5005" as a string.

Related