Python Forum
Raw Socket Error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Raw Socket Error (/thread-21349.html)



Raw Socket Error - therealherby - Sep-25-2019

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-programming-in-python-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))



RE: Raw Socket Error - markfilan - Oct-24-2019

check with simple..socket program