trying to use SOCK_RAW yields error "

T

Tzury Bar Yochay

I am trying to create raw socket:

server = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.getprotobyname('ip'))

As a result I get the following error:

Traceback (most recent call last):
File "tcpsrv.py", line 14, in <module>
server = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.getprotobyname('ip'))
File "/usr/lib/python2.5/socket.py", line 154, in __init__
_sock = _realsocket(family, type, proto)
socket.error: (93, 'Protocol not supported')


Does anybody have used socket.SOCK_RAW in the past?
 
T

Tzury Bar Yochay

When using SOCK_RAW, the family should be AF_PACKET,
not AF_INET. Note that you need root privileges to do so.

I changed as instructed:
server = socket.socket(socket.AF_PACKET, socket.SOCK_RAW,
socket.getprotobyname('ip'))

now I am getting:

Traceback (most recent call last):
File "tcpsrv.py", line 15, in <module>
server.bind((host,port))
File "<string>", line 1, in bind
socket.error: (19, 'No such device')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top