How to do raw Ethernet under Win32?

Leopold Faschalek fale.delete at
Thu Jul 24 12:39:27 CEST 2003

"Grant Edwards" <grante at> wrote in message
news:3f1ed31a$0$181$a1866201 at
> How does one do raw Ethernet under Win32?  Ultimately, I want
> to do it in a Python program, but if somebody can point me to a
> clue on how to do it from C, I could probably figure out the
> rest.
> I want to:
>  1) Send an arbitrary Ethernet packet.  [Well, not completely
>     arbitrary, the source MAC will be "right", but the protocol
>     number is a proprietary (not IP) one, and the packet isn't
>     anything standard.
>  2) Receive any incoming packets with a specified protocl
>     number -- same proto number as in 1) above.
> I've got a program that works under Linux, and I'd like to be
> able to port it to Win32...

the new winsock2.h supports more socket types:
 * Types
#define SOCK_STREAM     1               /* stream socket */
#define SOCK_DGRAM      2               /* datagram socket */
#define SOCK_RAW        3               /* raw-protocol interface */
#define SOCK_RDM        4               /* reliably-delivered message */
#define SOCK_SEQPACKET  5               /* sequenced packet stream */

so you have only to define 3 as type in the socket() call

Leopold Faschalek

> --
> Grant Edwards                   grante             Yow!  I have seen these
>                                   at               EGG EXTENDERS in my
>                                  Supermarket... I have
>                                                    theINSTRUCTIONS...

More information about the Python-list mailing list