Raw Sockets
dominic.j.steinitz@britishairways.com
dominic.j.steinitz@britishairways.com
Mon, 4 Mar 2002 14:45:05 +0000
Simon,
Thanks for the reply.
I wanted to send ICMP packets. Linux does support AF_RAW. This compiles and
runs on my linux system.
/*
* Create the socket.
*/
if ( (proto = getprotobyname("icmp")) == NULL)
err_quit("unknown protocol: icmp");
if ( (sockfd = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0)
err_sys("can't create raw socket");
Dominic.
"Simon Marlow" <simonmar@microsoft.com>@haskell.org on 04/03/2002 12:00:33
Sent by: glasgow-haskell-users-admin@haskell.org
To: "Dominic Steinitz" <dominic.j.steinitz
<glasgow-haskell-users
cc:
bcc:
Subject: RE: Raw Sockets
> How do I use raw sockets? According to the documentation I
> can use AF_RAW.
> It also refers the user to the implementation in
> fptools/hslibs/net/SocketPrim.lhs. Do I really need to do
> this and if so
> how do I get it?
The SocketPrim library (aka Network.Socket) really only supports AF_INET
and AF_UNIX. Many of the other AF_ things are quite system-dependent;
eg. Linux doesn't have AF_RAW.
The documentation is a bit slack, although it does mention at the top of
the Family(..) definition that "your mileage may vary depending on the
OS you use".
Do you really want a raw socket, or will a datagram (UDP) socket do? If
so, you can just pass Datagram as the SocketType argument to
SocketPrim.socket.
Cheers,
Simon
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
-------------------------------------------------------------------------------------------------
Save time by using an eTicket and our Self-Service Check-in Kiosks.
For more information go to http://www.britishairways.com/eservice1