#include <H3DNetworkingUtils/RemoteUDPServer.h>
Public Member Functions | |
RemoteUDPServer () | |
Constructor. | |
virtual | ~RemoteUDPServer () |
Destructor. | |
Static Public Attributes | |
static H3D::H3DNodeDatabase | database |
The X3D interface. | |
Protected Member Functions | |
virtual void | sendThisPacket (Packet &packet) |
Write a single packet of data to socket. | |
virtual void | receiveLoop () |
This function runs in a new thread. | |
virtual void | sendLoop () |
This function runs in a new thread. | |
virtual void | startServer (int port_number) |
Start the server. |
The RemoteUDPServer class starts a Remote server using a UDP port.
This is because it will then try to send whenever the value changes - i.e. from the haptics loop itself. This will fail, because the haptics loop has special capabilities which seem to prevent it using sockets. You probably don't want it to interrupt haptics to do socket stuff anyway. Make sure you set periodic send true if you are routing in from the haptics thread. When the client first connects, it sends a pulse packet to the server. The servers responds with a pulse.
Examples:
It starts listening on the given port for a connection from a Remote Client, then continues with the base class's behaviour using the port for comms. UDP is connectionless, data can come from any client. In our usage, it should always come from the same client, although currently this is not checked. When open is changed from false to true, the listening port is monitored for a connection from a client. When it is changed from true to false, the connection is closed. At present, only one remote connection is handled at any one time.
void RemoteUDPServer::receiveLoop | ( | ) | [protected, virtual] |
This function runs in a new thread.
} while (true);
Reimplemented from H3DNetworkingUtils::RemoteConnection.
References H3DNetworkingUtils::RemoteConnection::isConnected, H3DNetworkingUtils::Packet::isHeartBeat(), H3DNetworkingUtils::Packet::receive(), H3DNetworkingUtils::Packet::send(), H3DNetworkingUtils::RemoteConnection::showInfo(), and InetAddr::text().
void RemoteUDPServer::startServer | ( | int | port_number | ) | [protected, virtual] |
Start the server.
showInfo(tmp);
Implements H3DNetworkingUtils::RemoteServer.
References H3DNetworkingUtils::RemoteUDPClient::PULSE_PERIOD, InetAddr::scanPort(), and H3DNetworkingUtils::RemoteConnection::showInfo().