Ahmed Alnaqbi
Ahmed Alnaqbi

Reputation: 11

Data over Ethernet raspberry pi

I am using raspberry pi 4 model B, and I am trying to communicate with my pc using Ethernet. I wrote a python code that create a socket with the following:

import socket
   
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
   
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 
sock.bind((UDP_IP, UDP_PORT))

while True:
  data, addr = sock.recvfrom(1024) 

This code worked over the wifi, so I googled it and I found that we should use “socket.AF_PACKET” instead. Does someone have any idea? Also I noticed that there is 2 ip when I write ifconfig, one is under lo and the other is under wlan0.

Upvotes: 0

Views: 758

Answers (1)

Bob Goddard
Bob Goddard

Reputation: 977

lo, 127.0.0.1 is loopback and is only applicable to the system it is seen on. Virtually all systems will have one. You should use the IP address from wlan0.

Upvotes: 1

Related Questions