问题描述
一次项目,Python需要调用MATLAB,在MATLAB中进行计算,并将在MATLAB中的计算结果返回给Python。网上大多都是借助于MATLAB 自带的引擎 API(matlab.engine),但单次调用或每次调用启动MATLAB耗时太长了,所以思路转向使用socket通信。
代码
Python的utils模块
from socket import *
class UdpUtils:
def __init__(self, config):
self.remote_addr = config["remote_addr"]
self.local_addr = config["local_addr"]
self.udp = socket(AF_INET, SOCK_DGRAM)
self.udp.bind(self.local_addr)
# 发送消息
def<