'Enabling ethernet connection between Teensy 4.1 and intel-NUC

I am trying to establize socket connection between Teensy 4.1 and intel-NUC(Using Ubuntu) directly.

What I tried : I have connected Teensy 4.1 to my local ethernet switch where my PC and intel-NUC both are connected via ethernet cable. I was able to perform UDP socket communication in between teensy to PC and teensy to NUC both. All works fine.

Problem : (I am frm electronics background and know very little about networking.) I dont want to use a switch so I tried to connect Teensy with NUC directly via ethernet cable and the same code doesnt work anymore.

Is it even possible ? Do I have to make some changes for this to work ?

Teensy is programmed into arduino and in NUC I am using python. Python code I am sharing below.

import socket
UDP_IP = "192.168.10.8" (IP of Teensy)
UDP_PORT = 12345
MESSAGE = b".."
print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    print("received message: %s from" % data,end="")
    print(addr)
    break


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source