如何使用java代码/补丁释放(或重置)服务器端口
我在做一个Java项目。我正在使用JADE服务器进行监听 连接端口并接收数据。另外,我正在使用MATLAB终端运行 将输出发送到java控制台的脚本。我需要运行这个MATLAB 多次编写脚本
但对于每次迭代,我都必须重置服务器端口。不做 因此,它抛出了一个绑定socket错误
我想知道,有没有一种方法(java代码/补丁)可以释放和重置 每次运行程序后使用的端口(socket端口)?在eclipse中,我 点击控制台上的“红色”按钮可以释放一个端口。然而,我的 项目应该独立于此类点击
# 1 楼答案
插座setReuseAddress(true);