我试图打开一个套接字,它将接收通过Active Sync网络发送到Windows Mobile设备的所有数据包。Windows Mobile 6 - .net Socket建议[Compact Framework 3.5]
我使用代码:CS Network Sniffer for Windows
具体做法是:
//For sniffing the socket to capture the packets has to be a raw socket, with the
//address family being of type internetwork, and protocol being IP
mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Raw, ProtocolType.IP);
//Bind the socket to All Network Communication
mainSocket.Bind(new IPEndPoint(IPAddress.Parse("169.254.2.1"), 0));
我通过活动同步
特异性结合的IP设置和以下套接字选项不可用在Windows Mobile上,是否有任何其他选项可以在Windows Mobile上使用以获得相同的效果?我看到在MSDN上没有太大的帮助名单 - msdn.microsoft.com/en-us/library/aa926870.aspx
//Set the socket options
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IPv4 packets
SocketOptionName.HeaderIncluded,
true);
byte[] byTrue = new byte[4] { 1, 0, 0, 0 };
byte[] byOut = new byte[4] { 1, 0, 0, 0 }; //Capture outgoing packets
//Socket.IOControl is analogous to the WSAIoctl method of Winsock 2
//IOControlCode.ReceiveAll is equivalent to SIO_RCVALL constant of Winsock 2
mainSocket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);
最后的代码,即可获得:
//Start receiving the packets asynchronously
mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
new AsyncCallback(OnReceive), null);
再次,我的目标是通过Active Sync网络在我的Windows Mobile设备上的TCP和UDP的所有端口上接收所有传入数据包。 任何帮助,建议或代码非常感谢,C#,VB.net,C++都很好:)