I have the following problem:
I have a UDP server on my guest (Ubuntu 16.04) and a Client on my Host (Windows 10).
If I send messages from the host to the guest, the guest does not listen.
If I send messages from the guest to the host, the host listens normally.
I need the guest to listen to messages sent from the host or my smartphone that is on the same network, can someone help me?
My project depends on an application on my smartphone sending UDP messages to my virtual machine (Ubuntu 16.04)
This is my code:
Server:
import argparse
import math
import clipboard
import keyboard
from pythonosc import dispatcher
from pythonosc import osc_server
def print_volume_handler(unused_addr, args, volume):
#print("[{0}] ~ {1}".format(args[0], volume))
print(volume)
keyboard.press_and_release('up')
def print_compute_handler(unused_addr, args, volume):
try:
print("[{0}] ~ {1}".format(args[0], args[1](volume)))
except ValueError: pass
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
default="192.168.0.5", help="The ip to listen on")
parser.add_argument("--port",
type=int, default=5005, help="The port to listen on")
args = parser.parse_args()
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/1/push1", print)
dispatcher.map("/filter", print)
#dispatcher.map("/1/push2", print_volume_handler, "Volume")
dispatcher.map("/1/push3", print_volume_handler, "Texto")
dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)
server = osc_server.ThreadingOSCUDPServer(
(args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()
Client:
import argparse
import random
import time
from pythonosc import udp_client
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="192.168.0.5",
help="The ip of the OSC server")
parser.add_argument("--port", type=int, default=5005,
help="The port the OSC server is listening on")
args = parser.parse_args()
client = udp_client.SimpleUDPClient(args.ip, args.port)
for x in range(20):
client.send_message("/filter", random.random())
client.send_message("/logvolume", random.random())
client.send_message("/1/push1", random.random())
print('Enviado')
time.sleep(1)
UDP messages between guest and another PC
-
- Volunteer
- Posts: 5105
- Joined: 19. Sep 2009, 04:44
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows 10,7 and earlier
- Location: Sydney, Australia
Re: UDP messages between guest and another PC
If it works in one direction but not the other, I doubt that it is a VirtualBox problem. The first thing I would check would be firewall settings (or temporarily disable the firewalls on host and guest to test).
Bill
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: UDP messages between guest and another PC
Try searching the Virtualbox manual PDF for 'UDP': https://download.virtualbox.org/virtual ... Manual.pdf. If Virtualbox knows anything about UDP capabilities or troubles, it will be in the manual.
FWIW there is a mention of not listening reliably to UDP broadcasts in a guest using NAT, https://www.virtualbox.org/manual/ch06. ... imitations
FWIW there is a mention of not listening reliably to UDP broadcasts in a guest using NAT, https://www.virtualbox.org/manual/ch06. ... imitations