SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <UDPSocket.h>
Public Member Functions | |
UDPSocket () | |
UDPSocket (unsigned short localPort) | |
UDPSocket (const string &localAddress, unsigned short localPort) | |
void | DisconnectFromHost () |
void | SendDataGram (const void *buffer, int bufferLen, const string &foreignAddress, unsigned short foreignPort) |
int | RecvDataGram (void *buffer, int bufferLen, string &sourceAddress, unsigned short &sourcePort) |
void | SetMulticastTTL (unsigned char multicastTTL) |
void | JoinGroup (const string &multicastGroup) |
void | LeaveGroup (const string &multicastGroup) |
Public Member Functions inherited from CSocket | |
virtual | ~CSocket () |
string | GetLocalAddress () |
unsigned short | GetLocalPort () |
void | BindLocalPort (unsigned short localPort) |
void | BindLocalAddressAndPort (const string &localAddress, unsigned short localPort=0) |
unsigned long int | GetReadBufferSize () |
void | SetReadBufferSize (unsigned int nSize) |
void | SetNonBlocking (bool bBlocking) |
void | ConnectToHost (const string &foreignAddress, unsigned short foreignPort) |
void | Send (const void *buffer, int bufferLen) |
int | Recv (void *buffer, int bufferLen) |
string | GetPeerAddress () |
unsigned short | GetPeerPort () |
CSocket & | operator<< (const string &sStr) |
CSocket & | operator>> (string &sStr) |
virtual int | OnDataRead (unsigned long timeToWait=ULONG_MAX) |
void | SetBindToDevice (const string &sInterface) |
Private Member Functions | |
void | SetBroadcast () |
Additional Inherited Members | |
Public Types inherited from CSocket | |
enum | SocketType { TcpSocket = SOCK_STREAM, UdpSocket = SOCK_DGRAM, UnknownSocketType =-1 } |
enum | NetworkLayerProtocol { IPv4Protocol = AF_INET, IPv6Protocol = AF_INET6, UnknownNetworkLayerProtocol = -1 } |
enum | ReadResult { DATA_ARRIVED = 0, DATA_TIMED_OUT = ETIMEDOUT, DATA_EXCEPTION = 255 } |
Protected Member Functions inherited from CSocket | |
CSocket (SocketType type, NetworkLayerProtocol protocol) | |
CSocket (int sockDesc) | |
Static Protected Member Functions inherited from CSocket | |
static void | FillAddr (const string &localAddress, unsigned short localPort, sockaddr_in &localAddr) |
Protected Attributes inherited from CSocket | |
int | m_sockDesc |
UDP Socket class.
Definition at line 251 of file UDPSocket.h.
UDPSocket::UDPSocket | ( | ) |
Construct a UDP socket
SocketException | thrown if unable to create UDP socket |
Definition at line 299 of file UDPSocket.cpp.
References SetBroadcast().
UDPSocket::UDPSocket | ( | unsigned short | localPort | ) |
Construct a UDP socket with the given local port
localPort | local port |
SocketException | thrown if unable to create UDP socket |
Definition at line 304 of file UDPSocket.cpp.
References CSocket::BindLocalPort(), and SetBroadcast().
UDPSocket::UDPSocket | ( | const string & | localAddress, |
unsigned short | localPort | ||
) |
Construct a UDP socket with the given local port and address
localAddress | local address |
localPort | local port |
SocketException | thrown if unable to create UDP socket |
Definition at line 311 of file UDPSocket.cpp.
References CSocket::BindLocalAddressAndPort(), and SetBroadcast().
void UDPSocket::DisconnectFromHost | ( | ) |
Unset foreign address and port
SocketException | thrown if unable to disconnect UDP socket Unset foreign address and port |
SocketException | thrown if unable to disconnect UDP socket |
Definition at line 318 of file UDPSocket.cpp.
References CSocket::m_sockDesc.
void UDPSocket::JoinGroup | ( | const string & | multicastGroup | ) |
Join the specified multicast group
multicastGroup | multicast group address to join |
SocketException | thrown if unable to join group |
Definition at line 371 of file UDPSocket.cpp.
References CSocket::m_sockDesc.
void UDPSocket::LeaveGroup | ( | const string & | multicastGroup | ) |
Leave the specified multicast group
multicastGroup | multicast group address to leave |
SocketException | thrown if unable to leave group |
Definition at line 386 of file UDPSocket.cpp.
References CSocket::m_sockDesc.
int UDPSocket::RecvDataGram | ( | void * | buffer, |
int | bufferLen, | ||
string & | sourceAddress, | ||
unsigned short & | sourcePort | ||
) |
Read read up to bufferLen bytes data from this socket. The given buffer is where the data will be placed
buffer | buffer to receive data |
bufferLen | maximum number of bytes to receive |
sourceAddress | address of datagram source |
sourcePort | port of data source |
SocketException | thrown if unable to receive datagram |
Definition at line 346 of file UDPSocket.cpp.
References CSocket::m_sockDesc.
void UDPSocket::SendDataGram | ( | const void * | buffer, |
int | bufferLen, | ||
const string & | foreignAddress, | ||
unsigned short | foreignPort | ||
) |
Send the given buffer as a UDP datagram to the specified address/port
buffer | buffer to be written |
bufferLen | number of bytes to write |
foreignAddress | address (IP address or name) to send to |
foreignPort | port number to send to |
SocketException | thrown if unable to send datagram |
Definition at line 333 of file UDPSocket.cpp.
References CSocket::FillAddr(), and CSocket::m_sockDesc.
|
private |
Definition at line 401 of file UDPSocket.cpp.
References CSocket::m_sockDesc.
Referenced by UDPSocket().
void UDPSocket::SetMulticastTTL | ( | unsigned char | multicastTTL | ) |
Set the multicast TTL
multicastTTL | multicast TTL |
SocketException | thrown if unable to set TTL |
Definition at line 363 of file UDPSocket.cpp.
References CSocket::m_sockDesc.