SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWMulticastSocket Class Reference

Extends RWSocket to provide support for multicast UDP sockets. More...

#include <rw/network/RWMulticastSocket.h>

Inheritance diagram for RWMulticastSocket:
RWSocket

Public Member Functions

 RWMulticastSocket ()
 
 RWMulticastSocket (const RWSockType &socketType)
 
 RWMulticastSocket (SOCKET existingSocket)
 
void joinGroup (const RWInetAddr &group, const RWInetAddr &localAddr=RWInetAddr())
 
void joinGroup (const RWInet6Addr &group, unsigned int inter=0)
 
void leaveGroup (const RWInetAddr &group, const RWInetAddr &localAddr=RWInetAddr())
 
void leaveGroup (const RWInet6Addr &group, unsigned int inter=0)
 
RWMulticastSocketoperator= (const RWSocket &socket)
 
void setInterface (const RWInetAddr &inter)
 
void setInterface (unsigned int inter)
 
void setLoopback (bool loop)
 
void setScope (unsigned int scope)
 
- Public Member Functions inherited from RWSocket
 RWSocket ()
 
 RWSocket (const RWSocket &s)
 
 RWSocket (const RWSockType &socketType)
 
 RWSocket (SOCKET existingSocket)
 
RWSocket accept (RWSockAddr *addr=0) const
 
void bind (const RWSockAddrBase &address)
 
void close ()
 
void closesocket ()
 
void connect (const RWSockAddrBase &address)
 
RWSockAddr getpeername () const
 
SOCKET getSocket () const
 
RWSockAddr getsockname () const
 
void getsockopt (int level, int option, void *optval, RWSockLenType *optlen) const
 
int getsockopt (int option) const
 
RWSockType getsocktype () const
 
RWCString id (unsigned level=0) const
 
void ioctl (long cmd, void *arg) const
 
void ioctl (long cmd, int arg) const
 
int ioctl (long cmd) const
 
void ioctlsocket (long cmd, void *arg) const
 
void ioctlsocket (long cmd, int arg) const
 
int ioctlsocket (long cmd) const
 
bool isValid () const
 
void listen (const RWSockAddrBase &addr, int backlog=5)
 
void listen (int backlog=5) const
 
RWSocketoperator= (const RWSocket &s)
 
RWNetBuf recv (int flags=0) const
 
int recv (char *buf, int len, int flags=0, RWNetBuf::State *s=0) const
 
RWNetBuf recvAtLeast (int n) const
 
int recvAtLeast (char *buf, int len, int n, RWNetBuf::State *s=0) const
 
RWNetBuf recvfrom (RWSockAddr *addr=0, int flags=0) const
 
int recvfrom (char *buf, int len, RWSockAddr *addr=0, int flags=0, RWNetBuf::State *state=0) const
 
int recvmsg (msghdr *msg, int flags=0, RWNetBuf::State *s=0) const
 
int send (const RWCString &buf, int flags=0) const
 
int send (const char *buf, int len, int flags=0) const
 
void sendAtLeast (const RWCString &buf) const
 
int sendAtLeast (const RWCString &buf, int n) const
 
void sendAtLeast (const char *buf, int len) const
 
int sendAtLeast (const char *buf, int len, int n) const
 
int sendmsg (msghdr *msg, int flags=0) const
 
int sendto (const RWCString &buf, const RWSockAddrBase &to, int flags=0) const
 
int sendto (const char *buf, int len, const RWSockAddrBase &to, int flags=0) const
 
void setsockopt (int level, int option, void *optval, int optlen) const
 
void setsockopt (int option, int optval) const
 
void shutdown (int how=2) const
 
void shutdownread () const
 
void shutdownwrite () const
 
void socket (const RWSockType &type)
 

Additional Inherited Members

- Protected Member Functions inherited from RWSocket
void clearError () const
 
int lastError () const
 
void raise (const char *funcName, int err) const
 
void raise (const char *funcName) const
 
void raiseUnlessWouldBlock (const char *funcName, int err) const
 
void raiseUnlessWouldBlock (const char *funcName) const
 
- Static Protected Member Functions inherited from RWSocket
static void doRaise (int err, const char *funcName)
 
- Protected Attributes inherited from RWSocket
SOCKET socket_
 

Detailed Description

RWMulticastSocket is derived from RWSocket, providing an extended interface to support multicast UDP sockets.

Constructor & Destructor Documentation

RWMulticastSocket::RWMulticastSocket ( )

Default constructor. Sets the socket to an invalid state. You must initialize it with a call to socket(), connect(), bind(), or listen() before it can be used.

RWMulticastSocket::RWMulticastSocket ( const RWSockType socketType)

Creates an unconnected socket of the specified type. The resulting socket must be bound to an address using bind(), connect(), or listen() before it can be used.

Note
In order to effectively take advantage of the methods provided in this class, the RWSockType instance should represent a UDP socket type.
RWMulticastSocket::RWMulticastSocket ( SOCKET  existingSocket)

Creates an RWSocket that encapsulates the C socket.

Member Function Documentation

void RWMulticastSocket::joinGroup ( const RWInetAddr group,
const RWInetAddr localAddr = RWInetAddr() 
)

Joins an IPv4 multicast socket group. If localAddr is specified, then it will be used as the local interface for receiving messages from the group, otherwise an interface will be chosen by the system.

void RWMulticastSocket::joinGroup ( const RWInet6Addr group,
unsigned int  inter = 0 
)

Joins an IPv6 multicast socket group. If interface is specified, it will be used as the local interface for receiving messages from the group, otherwise an interface will be chosen by the system.

Condition:
This method is available only on systems that support IPv6-based socket addresses.
void RWMulticastSocket::leaveGroup ( const RWInetAddr group,
const RWInetAddr localAddr = RWInetAddr() 
)

Leaves an IPv4 mulitcast socket group. The arguments to this function should match those passed to joinGroup() when the socket joined the multicast group.

void RWMulticastSocket::leaveGroup ( const RWInet6Addr group,
unsigned int  inter = 0 
)

Leaves an IPv6 multicast socket group. The arguments to this function should match those passed to joinGroup() when the socket joined the multicast group.

Condition:
This method is available only on systems that support IPv6-based socket addresses.
RWMulticastSocket& RWMulticastSocket::operator= ( const RWSocket socket)

Assignment operator.

void RWMulticastSocket::setInterface ( const RWInetAddr inter)

Sets the local IPv4 address to be used when sending messages to the multicast group. If an interface is not specified, the system will choose one.

void RWMulticastSocket::setInterface ( unsigned int  inter)

Sets the local IPv6 address to be used when sending messages to the multicast group. If an interface is not specified, the system will choose one.

Condition:
This method is available only on systems that support IPv6-based socket addresses.
void RWMulticastSocket::setLoopback ( bool  loop)

Determines whether messages sent from this socket will also be received by this socket (if it is a member of the same group), or will be sent only to other members of the group. If loop is true, the sending socket will receive the message as well. The default is true.

void RWMulticastSocket::setScope ( unsigned int  scope)

Sets the maximum number of hops a packet is allowed to travel. The value of this argument is treated differently depending on whether this is an IPv4 or IPv6 multicast socket. If it is IPv4 based, the scope sets the TTL field of the message header. If it is IPv6 based, the scope sets the maximum number of hops (times the packet will be forwarded by a router) on the message header.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.