有关C#网络编成的问题? 有重谢哈
来源:百度知道 编辑:UC知道 时间:2024/06/07 19:10:04
private void button2_Click(object sender, EventArgs e)
{
UdpClient udpMesarch = new UdpClient(1910);
IPAddress multicastIpAddress = IPAddress.Parse("239.255.255.255");//group address
int iTTL = 5;
udpMesarch.JoinMulticastGroup(multicastIpAddress, iTTL);
string strMSearch = "";
strMSearch += "M-SEARCH * HTTP/1.1\r\n";
strMSearch += "Host: 239.255.255.250:1900\r\n";
strMSearch += "MAN: \"ssdp:discover\"\r\n";
strMSearch += "MX: 5\r\n";
strMSearch += "ST: urn:schemas-bmlinks-jp:service:print:1\r\n";
strMSearch += "RID: uuid:67e36cda-b28d-4ab0-82f7-2a53f71a7169\r\n";
{
UdpClient udpMesarch = new UdpClient(1910);
IPAddress multicastIpAddress = IPAddress.Parse("239.255.255.255");//group address
int iTTL = 5;
udpMesarch.JoinMulticastGroup(multicastIpAddress, iTTL);
string strMSearch = "";
strMSearch += "M-SEARCH * HTTP/1.1\r\n";
strMSearch += "Host: 239.255.255.250:1900\r\n";
strMSearch += "MAN: \"ssdp:discover\"\r\n";
strMSearch += "MX: 5\r\n";
strMSearch += "ST: urn:schemas-bmlinks-jp:service:print:1\r\n";
strMSearch += "RID: uuid:67e36cda-b28d-4ab0-82f7-2a53f71a7169\r\n";
你那东西具体是怎么回事搞不清楚,这么会有“所有的主机”,你的意思是你所在网络只有一个客户机,其他都是主机?
要接收应答应该专门用一个线程去侦听啊!