我正在尝试创建一个小应用程序,它从串行/通信端口读取数据并使用端口将数据广播到我的网络15000。
在 Windows 和 Linux(使用 Mono)上一切正常,但我Socket Exception在 macOS 上收到以下消息:Access denied
我尝试使用提升的权限运行我的应用程序:
须藤单声道 ./SerialMonitor.exe
但这也行不通。
有什么办法可以摆脱那个异常吗?为什么它在 Windows 和 Linux 上运行没有任何问题?
这是我的代码:
using System;
using System.IO.Ports;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace SerialMonitor
{
class MainClass
{
static SerialPort mSerial = new SerialPort();
static String[] mSerialPorts;
static UdpClient mNetwork;
static IPEndPoint mIP;
static String mData = "";
public static void Main(string[] args)
{
mNetwork = new UdpClient();
mIP = new IPEndPoint(IPAddress.Parse("192.168.1.255"), 15000);
mSerialPorts = SerialPort.GetPortNames();
Console.WriteLine("Select …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
const N: usize = 10000;
const S: usize = 7000;
#[derive(Copy, Clone, Debug)]
struct T {
a: f64,
b: f64,
f: f64
}
fn main() {
let mut t: [T; N] = [T {a: 0.0, b: 0.0, f: 0.0}; N];
for i in 0..N {
t[i].a = 0.0;
t[i].b = 1.0;
t[i].f = i as f64 * 0.25;
}
for _ in 0..S {
for i in 0..N {
t[i].a += t[i].b * t[i].f;
t[i].b -= t[i].a * t[i].f; …Run Code Online (Sandbox Code Playgroud)