I want to try create a client for my server side (with send raw data over the ethernet protocole) But i have this error :
File "/usr/lib/python2.7/socket.py", line 206, in accept
sock, addr = self._sock.accept()
socket.error: [Errno 95] Operation not supported
Although I am calling this way: sudo python server.py
And this is my server.py codes:
from socket import *
server= socket(AF_PACKET,SOCK_RAW)
host='eth0'
port=4096
address=(host,port)
server.bind(address)
print("started listening " + host + ": " ,port)
client,addr=server.accept()
print("Got a connection from " + addr[0], ": ",addr[1])
while True:
data =client.recv(4096)
print("Received" + data + " from the client" )
print ("proccesing data")
if(data == "Hello server"):
client.send(("Hello client").encode('utf-8'))
print(" Proccesing done. \n Reply Send")
elif(data =="disconnect"):
client.send(("Goodbye").encode('utf-8'))
client.close()
break
else:
client.send((" Invalid data ").encode('utf-8'))
print(" Proccessing done Invalid data . \n Reply send ")
Accoriding to Sam Maso 's comment and it is workig. I hope this is help for other people.