我使用以下代码来braodacst UDP请求。我的电脑上有两张网卡。一个连接到LAN,另一个通过电缆连接到另一台计算机。所以,我的braodcast在局域网上运行良好,但它不在直接连接到计算机的电缆上。你能帮帮我吗?
我的代码:
Socket sending_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
IPAddress send_to_address = null;
send_to_address = IPAddress.Broadcast;
sending_socket.EnableBroadcast = true;
IPEndPoint sending_end_point = new IPEndPoint(send_to_address, port);
sending_socket.SendTo(buffer, sending_end_point);