0
我正在Linux上使用MonoDevelop開發端口打開應用程序。 服務器應用程序使用iptables來開啓/關閉某些端口命令:在Linux上使用Mono打開端口
iptables -A INPUT -j DROP
它的成功運用一定的規則,如:
iptables -A INPUT -p udp --dport 606:610 -j LOG
然後我創建了UdpClient的客戶端應用程序發送敲門要求
private static UdpClient udp;
public static void sendmessage (string message, string host, short port)
{
try
{
IPAddress ip=IPAddress.Parse(host);
if(udp==null)
udp=new UdpClient();
byte[] b=ASCIIEncoding.ASCII.GetBytes(message);
udp.Send(b,b.Length,new IPEndPoint(ip,port));
}
catch (Exception exc)
{
throw exc;
}
}
但是,這個客戶端應用程序崩潰,似乎是當服務器關閉每個端口時引發異常。
有沒有解決方案發送數據包,不關心服務器是否關閉/打開某些端口?