如何监听无线设备请求的套接字? [英] How to listen socket requested from wireless device?
本文介绍了如何监听无线设备请求的套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为标题。
As title.
private void StartServerToListen()
{
try
{
ServerPort = 1001;
IPEndPoint ServerIPEndPoint = new IPEndPoint(IPAddress.Any, ServerPort);
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
ServerSocket.Bind(ServerIPEndPoint);
ServerSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.AcceptConnection, true);
//ServerSocket.SetSocketOption(SocketOptionLevel.Tcp,SocketOptionName.
ServerSocket.Listen(32767);
ServerSocket.BeginAccept(new AsyncCallback(ServerBeginAccept), ServerSocket);
}
catch (SocketException se)
{
LogAccess.WriteSocketException(ref se, DateTime.Now);
}
catch (Exception ex)
{
LogAccess.WriteException(ref ex);
}
}
这是我如何从以太网开始监听套接字的子程序。它在以太网内部(有线)很好用,但是我无法接受来自无线设备的任何套接字连接。请教我一下我应该改变接受soc来自无线设备的连接。并且,我确保服务器端和客户端连接到同一个AP,在同一子网掩码中,IP为192.168.x。*
This is the subroutine that how I start to listen socket from Ethernet. It works well inside the Ethernet (with wire ) but I can't accept any socket connection from wireless device. Please teach me what should I change to accept socket connection from wireless device. And, I ensure that the server side and client side are connected to same AP, in the same subnet mask, IPs are 192.168.x.*
推荐答案
它不应该无论设备是有线还是无线,只要它们连接到同一个子网(相同的IP地址范围和网络掩码),并且它们在相同的端口号上运行/侦听。
如果设备未配置/连接到同一子网,则需要通过UDP进行广播或多播以查找和通信。
It should not matter whether the device is wired or wireless as long as they are connected to the same subnet (same IP address range and netmask) and they are running/listening on the same port number.
If the device is not configured/connected to same subnet you would need broadcasting or multi-casting via UDP to find and communicate.
这篇关于如何监听无线设备请求的套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文