#include <MNSocket.h>
Inheritance diagram for MNSocket:
Public Types | |
enum | SocketFlags { TakeoverFlag = 0x1 } |
Public Member Functions | |
bool | mcast_join_new (struct sockaddr *sa, char *ifname) |
int | mcast_leave (int sockfd, const struct sockaddr *sa, char *ifname) |
int | mcast_set_if (int sockfd, const char *ifname) |
int | mcast_set_loop (int sockfd, int onoff) |
int | mcast_set_ttl (int sockfd, int val) |
int | mcast_get_if (int sockfd) |
int | mcast_get_loop (int sockfd) |
int | mcast_get_ttl (int sockfd) |
void | make_socket (int type) |
void | make_socket (int domain, int type) |
void | remake_socket (int type) |
void | remake_socket (int domain, int type) |
void | listen () |
int | bind (int port) |
int | bind (int port, const char *hostname) |
void | broadcast () |
const char * | get_ipaddr (char *buffer, size_t len) |
bool | get_sock_name (struct sockaddr_in &addr) const |
bool | get_addr (struct sockaddr_in &addr) const |
another name for get_sock_name, may be easier to remember | |
int | get_socktype () |
Returns SOCK_STREAM if socket is TCP and SOCK_DGRAM if socket is UDP. | |
MNSocket (MNSocket &orig, int socketflags=0) | |
MNSocket () | |
MNSocket (int sock) | |
virtual | ~MNSocket () |
int | ok () |
int | port () |
void | master (bool controlSocket) |
virtual int | get_sockdesc () const |
virtual void | set_sockdesc (int socket) |
virtual void | update_ports () |
virtual bool | isUdp () const =0 |
int | l1_receive (struct msghdr *hdr) |
int | l1_receive (struct iovec *iov, int iovlen, struct sockaddr_in *dest) |
int | l1_receive (char *buffer, int max_len) |
int | send (struct iovec *iov, int iov_count, const struct sockaddr_in *dest) |
void | reuseaddress () |
void | linger () |
void | nolinger () |
void | nodelay () |
void | noblock () |
virtual void | connection_closed () |
virtual const char * | get_title () |
Static Public Member Functions | |
bool | set_addr (int port, const char *hostname, struct sockaddr_in &server_addr) |
bool | isMulticast (const char *hname) |
const char * | getLocalNameForAddr (struct in_addr *addr, char *buffer) |
|
|
|
Make a copy of the current socket. Either forbid the new object to control the socket (controlSocket==false) or pass the control. In the latter case, the caller must release the control of the original. |
|
|
|
|
|
|
|
Bind the valid, open socket to the given port. If the hostname parameter is a multicast address in dotted decimal notation, the try to join the multicast group as well. If the hostname is the name of an interface of the localhost, try to bind to that interface instead of INADDR_ANY. |
|
Bind the valid, open socket to the given port on an OS-selected interface (INADDR_ANY). |
|
|
|
|
|
another name for get_sock_name, may be easier to remember
|
|
Initialized or overwrite the internal variables my_port and my_address with the actual information of this bound and connected socket. If a buffer is provided, the dotted decimal notation of the address for this socket is written into the buffer, if possible, and a pointer to the buffer is returned. If no buffer is provided, the return value must be ignored.
|
|
Write the sockaddr_in structure for this socket into the OUT parameter that the caller provide.
|
|
Implements MNSocketBase.
|
|
Returns SOCK_STREAM if socket is TCP and SOCK_DGRAM if socket is UDP.
|
|
|
|
Helper function to retrieve on of the local hostnames, specifically the one that we need. It is useful when we have a client socket that was bound to the correct interface automatically using INADDR_ANY and now we want to communicate over the same interface again (as server socket, as UDP socket, etc). Using information about the existing socket, its name is established for passing to a remote host or process.
|
|
Check whether the given string is a multicast address in dotted decimal notation.
|
|
Function is used in child classes to tell the world what kind of protocol the socket is besed on. UDP child classes will return true and TCP child classes will return false.
Implemented in MNTCPSocket, and MNUDPSocket.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This function tries to join the given multicast interface with this valid, open socket. The advantage over the bind function with two parameters is that the local bind operation is explicit. Furthermore, an interface can be chosen explicitely. This doesn't work with the two-parameter bind call. But a three parameter bind call may be in order that solves both of these issues at the same time. Function works only for the first linux interface (eth0). a new function must be added that finds all interfaces on the machine and determines which are capable of multicast.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
send prepares the iovec structure for transmission with sendmsg and sends it to the given target.
|
|
This function fills the sockaddr_in structure in for the given port number and host name. If this is successful, true is returned, and false otherwise. The old version of the function returned the sockaddr_in structure itself, which had three disadvantages: It was not possible to know whether the operation was successful or not The entire structure had to be copied back and forth a few times, while a call-by-reference allows to fill in the target structure directly An extension for IPv6 is simple, and nearly interface compatible except for the return value.
|
|
|
|
|