Recent

Author Topic: Cannot receive broadcasting from linux running on a virtual machine.  (Read 2061 times)

sainimu78

  • Full Member
  • ***
  • Posts: 117
Host machine: Win7, IP:192.168.0.3
Virtual machine: VMWare, Ubuntu16.04 x64, IP:192.168.0.5, Bcast:192.168.0.255
Gateway both: 192.168.0.1
Broadcasting on segment: 192.168.0.255

UDP_Server: starts a thread calling IdUDPServer's RecvFrom(buf, len, 1000);
UDP_Client: calling IdUDPClient's SendTo(buf, len, '192.168.0.255', 1000);

Case 1: Works fine, both UDP_Server and UDP_Client run on the host machine.
Case 2: Works fine, both UDP_Server and UDP_Client run on the virtual machine.
Case 3: Works fine, UDP_Server run on the virtual machine, UDP_Client run on the host machine.
Case 4: Doesn't Work, UDP_Client run on the virtual machine, UDP_Server run on the host machine.

I test this with another virtual machine, VmWare, Win7x64, IP:192.168.146.6.
VMWare has 2 NICs, btw.
UDP_Client: calling IdUDPClient's SendTo(buf, len, '192.168.146.255', 1000);
All Cases above works fine then.

I have no idea about this, any words would be good.
« Last Edit: December 10, 2016, 03:36:39 pm by sainimu78 »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1314
    • Lebeau Software
Re: Cannot receive broadcasting from linux running on a virtual machine.
« Reply #1 on: December 11, 2016, 12:23:54 am »
UDP_Server: starts a thread calling IdUDPServer's RecvFrom(buf, len, 1000);

You do realize that TIdUDPServer is a multi-threaded component, right?  You don't need to call RecvFrom() manually, TIdUDPServer will handle that internally for you and fire its OnUDPRead event whenever a new packet is received.

UDP_Client: calling IdUDPClient's SendTo(buf, len, '192.168.0.255', 1000);

Also, make sure you are setting the BroadcastEnabled property to True on both client and server in order to send/receive broadcasts.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018