Allolib
1.0
C++ Components For Interactive Multimedia
|
Socket for receiving OSC packets. More...
Public Member Functions | |
Recv (uint16_t port, const char *address="", al_sec timeout=0) | |
bool | open (uint16_t port, const char *address="", al_sec timeout=0) |
bool | isOpen () |
const std::string & | address () const |
uint16_t | port () const |
bool | background () const |
Whether background polling is activated. | |
const char * | data () const |
Get current received packet data. | |
void | bufferSize (int n) |
Set size of internal buffer. | |
Recv & | handler (PacketHandler &v) |
Set packet handling routine. | |
Recv & | appendHandler (PacketHandler &v) |
Add a packet handler to list. All handlers get all messages. | |
int | recv () |
bool | start () |
Begin a background thread to poll the socket. More... | |
void | stop () |
Stop the background polling. | |
void | parse (const char *packet, int size, const char *senderAddr) |
void | loop () |
Static Public Member Functions | |
static bool | portAvailable (uint16_t port, const char *address="") |
static std::vector< std::shared_ptr< Message > > | parse (const char *packet, int size, TimeTag timeTag=1, const char *senderAddr=nullptr) |
Protected Attributes | |
std::vector< PacketHandler * > | mHandlers |
std::vector< char > | mBuffer |
al::Thread | mThread |
bool | mBackground |
std::string | mAddress = "" |
uint16_t | mPort = 0 |
bool | mOpen {false} |
Socket for receiving OSC packets.
Supports explicit polling or implicit background thread polling
Definition at line 399 of file al_OSC.hpp.
al::osc::Recv::Recv | ( | uint16_t | port, |
const char * | address = "" , |
||
al_sec | timeout = 0 |
||
) |
[in] | port | Port number (valid range is 0-65535) |
[in] | address | IP address. If empty, will bind all network interfaces to socket. |
[in] | timeout | < 0: block forever; = 0: no blocking; > 0 block with timeout |
int al::osc::Recv::recv | ( | ) |
Check for an OSC packet and call handler returns bytes read note: use while(recv()){} to ensure queue is fully flushed.
bool al::osc::Recv::start | ( | ) |
Begin a background thread to poll the socket.
The socket timeout controls the polling period. Returns whether the thread was started successfully.