Raw Sockets problem.

This is a discussion on Raw Sockets problem. within the C Programming forums, part of the General Programming Boards category; Right, so. I wanted to learn to use Raw Sockets so I could make a class for them, yes? Well, ...

  1. #1
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258

    Raw Sockets problem.

    Right, so. I wanted to learn to use Raw Sockets so I could make a class for them, yes? Well, I've hit a snag with using IP_HDRINCL with getsockopt();



    By default, Raw Sockets automatically build an IP header for you, by declaring IP_HDRINCL on a handle to a raw socket descriptor, you have to make the headers for the packets that are sent through it.

    This proves to be easier than I thought it would be and rather linear in reality, there is a problem however:

    http://rafb.net/paste/results/0DVWSz56.html

    That code shows me error code 10022 on line 118, I looked up the error code and it is caused by an invalid parameter on line 115 AKA setsockopt(); MSDN has told me it normally has something to do with the level parameter (param 2) of setsockopt. I checked at least 5 times, I am using IPPROTO_IP, which is valid, in conjunction with IP_HDRINCL which is also valid as stated by MSDN (certain levels used in setsockopt can only set certain options on the socket, both IPPROTO_IP and IPPROTO_IPV6 can use IP_HDRINCL.)


    Can anybody here help?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    IPPROTO_IP Socket Options

    The "Optval type" column specifies DWORD - that may be your "invalid parameter".

    gg

  3. #3
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    By default I thought that was it too, but I even went so far as to pull the code that makes the socket and sets the option out of a very good book over Network Programming on Windows.


    Edit, typecasts suck.
    Last edited by Mad_guy; 07-03-2005 at 01:39 PM.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    >> ...out of a very good book...
    My book says BOOL too, but you're the one getting "invalid parameter".

    Are you running this code on a Win2K machine or higher?
    If so, does the account running this code have Administrator privileges?

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sockets and UDP problem
    By ally153 in forum C Programming
    Replies: 5
    Last Post: 03-20-2006, 04:19 AM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. multiple UDP sockets with select()
    By nkhambal in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-17-2006, 06:36 PM
  4. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  5. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21