开发者

How to use raw sockets in WinCE5?

开发者 https://www.devze.com 2023-03-11 23:03 出处:网络
I need to use raw sockets in Windows CE 5.0. The following code always fails with error socket fai开发者_运维知识库led, err:10044.(The support for the specified socket type does not exist in this ad

I need to use raw sockets in Windows CE 5.0. The following code always fails with error

socket fai开发者_运维知识库led, err:10044.

(The support for the specified socket type does not exist in this address family.)

WSAData wsaData;
SOCKET s;
int n;

n = WSAStartup(MAKEWORD(2,0), &wsaData);

if (n < 0) {
  printf("WSAStartUp failed, err:%d\n", WSAGetLastError());
} else {
  s = socket(AF_INET, SOCK_RAW, IPPROTO_IP);

  if (s < 0)
  {
    printf("socket failed, err:%d\n", WSAGetLastError());
  }
}

What must I do for using raw sockets in Windows CE?


I find MSDN documentations for WinCE specific sockets are rather few, but the guide for desktop winsock is pretty nice.

I stumbled upon the following links when trying to write my very first socket app for WinCE 5.0:

  • Porting Socket Applications to Winsock
  • Porting Raw Socket to Winsock
  • Determining if Raw Sockets are supported

I hope you find them useful.

Note that even though the above articles are for desktop, I can use the concepts and codes with few modifications.


Raw IP sockets are not supported in Windows CE 5.0. You can use NDISUIO to send packets with arbitrary content.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号