Cannot use 2 IP for UDP server and client on the same BBB machine

Hi, I’m connecting 1 BBB with usb0 (UDP client 192.168.7.2) and ethernet cable (UDP server 192.168.7.51) to my PC. I can ssh to either IP address, and ping to another IP address. Also, firewall is turned OFF.

However, I cannot

On server side (192.168.7.51), I’m running server.py

import socket

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

udp_host = '192.168.7.2'
udp_port = 12345
print(udp_host)

try:
    sock.bind((udp_host,udp_port))
except Exception as e:
    print(f"Server side: Error bind(): {e}")

while True:
    print("Waiting for client...")
    data, addr = sock.recvfrom(1024)
    print("Received Message:", data, " from", addr)

On client side (192.168.7.2), I’m running client.py

import socket

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
udp_host = '192.168.7.51'
udp_port = 12345

print("UDP server target IP:", udp_host)
print("UDP server target Port:", udp_port)
msg = "Hello World!"
msg_bytes = msg.encode('utf-8')

try:
    sock.sendto(msg_bytes,(udp_host,udp_port))
except Exception as e:
    print(f"Client side: Error sendto(): {e}")

Client successfully sends the message, but server does NOT receive any message. Why is that, please?

  1. What server are you running?
  2. Are you sure your port is open on the server.
$sudo ufw status

Also, on your client

$arp -ae

If you don’t have arp, then $sudo apt install net-tools
It should bounce back the mac and IP of your server along with other stuff on the network, if this fails to show the server check your cabling and switch.

A bit confused. BBB connected to your PC via USB. Is the server a seperate machine ?
Does the BBB connected via ethernet also ?

As the server IP is on the same subject as the USB interface, trying to connect to if from the BBB will send packets down the USB interface. Is your PC setup yo route packets ?

If the BBB has both ethernet and USB connected and the IP addresses for both interfaces are on the same subject packets might go out the wrong interface when sending .

Really need more information on the setup.