Raw Sockets

Simon Marlow simonmar@microsoft.com
Mon, 4 Mar 2002 16:16:49 -0000


> Thanks for the reply.
>=20
> I wanted to send ICMP packets. Linux does support AF_RAW.=20
> This compiles and
> runs on my linux system.
>=20
>      /*
>        * Create the socket.
>       */
>      if ( (proto =3D getprotobyname("icmp")) =3D=3D NULL)
>           err_quit("unknown protocol: icmp");
>       if ( (sockfd =3D socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0)
>             err_sys("can't create raw socket");

It looks like you want SOCK_RAW, not AF_RAW.  GHC does support this,
with the 'Raw' socket type, something like this:

      proto <- getProtocolByName "icmp"
	s <- socket AF_INT Raw proto

Cheers,
	Simon