raw socket exapmle?
jeremy at beopen.com.bbs
jeremy at beopen.com.bbs
Mon Jul 17 15:40:06 EDT 2000
ge at nowhere.none (Grant Edwards) writes:
> In article <rFGb5.1091$6E.150413 at ptah.visi.com>, Grant Edwards wrote:
>
> >After looking at the source code for the socket module in 1.52
> >and 1.6a2, it doesn't look like either RAW or PACKET sockets
> >are supported.
> >
AF_INET / SOCK_RAW has been supported for a long time. You can find
examples of their use in some fairly old code I wrote to do ping and
traceroute: http://the-tech.mit.edu/~jeremy/python/
Some highlights are:
s = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_ICMP)
dest = (socket.gethostbyname(addr), 0)
s.sendto(packet, self.dest)
Note that the raw socket is not bound to any address! You used sendto
rather than send to specify the destination.
Jeremy
More information about the Python-list
mailing list