[vbox-dev] TCP Socket Polling?

Knut St. Osmundsen bird at innotek.de
Fri May 4 22:53:05 GMT 2007

Robert Zeljko wrote:
> I'm using RTTcpClientConnect and RTTcpRead/Write in my VBox device emulator to
> get some remote data.
> I can poll for the reads on the socket (bad), I can create a thread and wait on
> RTTcpSelectOne or plug-in my socket handle somewhere and get called back by the
> VBox framework.
> Creating a thread is an option but is more complicated (and I'm lazy) than
> simply registering a socket handle with the framework and waiting to be called
> back.
> QEMU has qemu_set_fd_handler2 to do that.
> Is there a way to do the same in VBox.

Afraid there isn't any interface similar to qemu_set_fd_handler2 for the 
simple reason that we haven't really needed it yet, nor have we found a 
100% portable way of implementing anything of that nature.

There is the poll interface that the DrvNAT.cpp uses to drive its stuff. 
But, I'm afraid this is only available to drivers since it was created 
specially for the NAT driver as a "temporary" solution. So, perhaps this 
isn't very useful unless you extended the concept to include devices.

A very simple way of polling which will work in a device emulation is to 
employ a timer and do the socket polling in the timer callback. This 
isn't terribly efficient of course, but it's simple if you just wish to 
try out a concept and don't wish to mess with thread ping-pong just yet.

I'm sorry that I can't dish up with a good and simple solution here (yet).

Kind Regards,

More information about the vbox-dev mailing list