oscpkt::UdpSocket Struct Reference

#include <udp.hh>

List of all members.

Public Types

enum  { OPTION_UNSPEC = 0, OPTION_FORCE_IPV4 = 1, OPTION_FORCE_IPV6 = 2, OPTION_DEFAULT = OPTION_FORCE_IPV4 }

Public Member Functions

void close ()
bool isOk () const
const std::string & errorMessage () const
bool isBound () const
int boundPort () const
std::string boundPortAsString () const
int socketHandle () const
std::string localHostName () const
std::string localHostNameWithPort () const
bool bindTo (int port, int options=OPTION_DEFAULT)
bool connectTo (const std::string &host, const std::string &port, int options=OPTION_DEFAULT)
bool connectTo (const std::string &host, int port, int options=OPTION_DEFAULT)
void setErr (const std::string &msg)
bool receiveNextPacket (int timeout_ms=-1)
void * packetData ()
size_t packetSize ()
SockAddrpacketOrigin ()
bool sendPacket (const void *ptr, size_t sz)
bool sendPacketTo (const void *ptr, size_t sz, SockAddr &addr)

Public Attributes

std::string error_message
int handle
SockAddr local_addr
SockAddr remote_addr
std::vector< char > buffer

Detailed Description

just a wrapper over the classical socket stuff

should be robust, simple to use, IPv6 ready (avoids all deprecated stuff such as gethostbyname etc), and portable (mac/linux/windows)

Try to avoid sending packets larger than 8192 because some other implementation may truncate them (python's DatagramRequestHandler of OSC.py for example).

Examples:

oscpkt_demo.cc, and oscpkt_test.cc.


Member Function Documentation

bool oscpkt::UdpSocket::bindTo ( int  port,
int  options = OPTION_DEFAULT 
) [inline]

open the socket and bind it to a port. Use this when you want to read incoming data on the specified port, using the function receiveNextDatagram.

Examples:
oscpkt_demo.cc, and oscpkt_test.cc.
bool oscpkt::UdpSocket::connectTo ( const std::string &  host,
const std::string &  port,
int  options = OPTION_DEFAULT 
) [inline]

open the socket, and prepare for sending datagrams to the specified host:port

Examples:
oscpkt_demo.cc, and oscpkt_test.cc.
bool oscpkt::UdpSocket::receiveNextPacket ( int  timeout_ms = -1  )  [inline]

wait for the next datagram to arrive on our bound socket. Return false in case of failure, or timeout. When the timeout_ms is set to -1, it will wait forever.

The datagram is available with the getDatagramData() / getDatagramSize() functions, the sender address can be retrieved with getDatagramOrigin().

Examples:
oscpkt_demo.cc, and oscpkt_test.cc.

The documentation for this struct was generated from the following file:
 All Classes Functions

Generated by  doxygen 1.6.2