I am trying to connect to a client computer in order to send integer values using UDP from my server computer. The problem arises (I believe) due to the server computer sending and listening to UDP communication in python, while the client receives and sends messages from a MATLAB script. Theoretically this arrangement should not matter since the UDP communication should not be affected by the coding language at all.
Server-side code (python):
import socket
commandVal = 0 #Message to be sent
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(np.uint8(commandVal), (hostIP, portNum)) #hostIP and portNum are defined separately
sock.connect((hostIP, portNum))
while True:
data, addr = sock.recvfrom(1024)
print("received message: %s" % data)
client-side code (MATLAB):
packetlength = 50
waitdur = 15000
mssgA = judp('receive',port,packetlength,waitdur);
if mssgA(1) == 0
judp('send',port, host,int8('error'))
else
judp('send',port, host,int8('success'))
I know the ports and IPs are defined correctly because I can send and receive messages if I use the MATLAB-based judp
function to communicate from the server end. When the python code is used, the message is sent to the client, but no 'error' or 'success' message is received in return. What is the issue here?
I have tried changing firewall settings, and going through the documentation for both judp
and socket
. I haven't found a solution yet.
from Server not receiving UDP messages from client (python to MATLAB)
No comments:
Post a Comment