2021年3月7日星期日

UDP: python server with simulink client OSError: [Errno 48] Address already in use from python

I am trying to send datetimes to simulink via python. (I have to use simulink, not just MATLAB)

Here is my python program for a UDP server

import socket  from datetime import datetime    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  sock.bind(("127.0.0.1", 12345))    while True:       data, addr = sock.recvfrom(256)       print(data)       message = bytes(str(datetime.now()), encoding='utf-8')       sock.sendto(message, addr)  

And here is my attempt at writing a receiver in Simulink enter image description here

I have set the simulink model to run indefinitely but I get an error:

OSError: [Errno 48] Address already in use from python  

Isn't it the point to use the same address to communicate? I understand the error is because it's between MATLAB and Python, so how do I get around it?

https://stackoverflow.com/questions/66416791/udp-python-server-with-simulink-client-oserror-errno-48-address-already-in-u March 01, 2021 at 12:48PM

没有评论:

发表评论