Python Forum

Full Version: Raw Socket Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am getting an "socket.error: [Errno 22] Invalid argument" error when calling sendto below. I made this simple version based on https://www.binarytides.com/raw-socket-p...hon-linux/. My google-fu has failed me. Any guesses as to what is wrong with the sendto call?

import socket, sys
from struct import *

try:
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
except socket.error, msg:
    print 'Socket could not be created. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()
    
packet='active=1'
dest_ip = '192.168.1.10'

s.sendto(packet, (dest_ip, 7))
check with simple..socket program