views:

247

answers:

1

Hi,
I'm fighting with raw sockets in Win32 and now I'm stuck, the soetsockopt funtion give me the 10022 error (invalid argument), but I think I pass the correct arguments... of course I'm wrong u_u'

sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP);
if (sock == SOCKET_ERROR)
{
  printf("Error socket(): %d", WSAGetLastError());
  return;
}
char on = 1;
error =  setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&on,sizeof(on)); 
if (sock == SOCKET_ERROR)
{
  printf("Error setsockopt(): %d", WSAGetLastError());
  return;
}

Anybody knows what happen to my code?

+1  A: 

As far as I remember you need to use int on = 1 instead of char...

Artyom
It's true! :D Thank you Artyom!
Alfred