nidas v1.2.3
|
Implementation of a socket, providing a C++ interface to system socket calls: socket,bind,listen,accept,setsockopt, etc. More...
#include <Socket.h>
Public Member Functions | |
SocketImpl (int domain, int type) | |
SocketImpl (int fd, const SocketAddress &remoteaddr) | |
SocketImpl (const SocketImpl &x) | |
Copy constructor. | |
SocketImpl & | operator= (const SocketImpl &rhs) |
Assignment operator. | |
~SocketImpl () | |
int | getFd () const |
int | getDomain () const |
Get the domain of this socket: AF_UNIX, AF_INET, etc, from sys/socket.h. | |
void | setBacklog (int val) |
const SocketAddress & | getLocalSocketAddress () const |
Get local socket address of this socket. | |
int | getLocalPort () const |
Get local port number of this socket. | |
const SocketAddress & | getRemoteSocketAddress () const |
Get remote socket address of this socket. | |
int | getRemotePort () const |
Get remote port number of this socket. | |
void | setReuseAddress (bool val) |
void | setNonBlocking (bool val) |
bool | isNonBlocking () const |
void | setTcpNoDelay (bool val) |
Set the TCP_NODELAY (man 7 tcp) option on the socket. | |
bool | getTcpNoDelay () |
Get the TCP_NODELAY (man 7 tcp) option on the socket. | |
void | setTimeout (int val) |
Set the timeout for receive(), recv(), and recvfrom() methods. | |
int | getTimeout () const |
void | setKeepAlive (bool val) |
Set or unset the SO_KEEPALIVE socket option. | |
bool | getKeepAlive () const |
Get the current value of the SO_KEEPALIVE socket option. | |
void | setKeepAliveIdleSecs (int val) |
Set the number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes (TCP_KEEPIDLE). | |
int | getKeepAliveIdleSecs () const |
Get the current value of TCP_KEEPIDLE on this socket. | |
int | getInQueueSize () const |
Get number of bytes currently unread in the local input queue. | |
int | getOutQueueSize () const |
Get number of bytes currently unsent in the local output queue. | |
void | close () |
void | bind (int port) |
void | bind (const Inet4Address &addr, int port) |
void | bind (const SocketAddress &sockaddr) |
void | listen () |
Socket * | accept () |
void | connect (const std::string &dest, int port) |
void | connect (const Inet4Address &addr, int port) |
void | connect (const SocketAddress &addr) |
void | receive (DatagramPacketBase &packet) |
void | receive (DatagramPacketBase &packet, Inet4PacketInfo &info, int flags=0) |
size_t | recv (void *buf, size_t len, int flags=0) |
Receive data on a socket. | |
size_t | recvfrom (void *buf, size_t len, int flags, SocketAddress &from) |
void | send (const DatagramPacketBase &packet, int flags=0) |
size_t | send (const void *buf, size_t len, int flags=0) |
send data on socket. | |
size_t | send (const struct iovec *iov, int iovcnt, int flags=0) |
size_t | sendto (const void *buf, size_t len, int flags, const SocketAddress &to) |
size_t | sendto (const struct iovec *iov, int iovcnt, int flags, const SocketAddress &to) |
void | sendall (const void *buf, size_t len, int flags=0) |
send all data in buffer on socket, repeating send() as necessary, until all data is sent (or an exception occurs). | |
void | joinGroup (Inet4Address groupAddr) |
Join a multicast group on all interfaces. | |
void | joinGroup (Inet4Address groupAddr, const Inet4NetworkInterface &) |
Join a multicast group on a specific interface. | |
void | leaveGroup (Inet4Address groupAddr) |
Leave a multicast group on all interfaces. | |
void | leaveGroup (Inet4Address groupAddr, const Inet4NetworkInterface &iaddr) |
Leave a multicast group on a given interface. | |
void | setReceiveBufferSize (int size) |
int | getReceiveBufferSize () |
void | setSendBufferSize (int size) |
int | getSendBufferSize () |
void | setTimeToLive (int val) |
int | getTimeToLive () const |
void | setPktInfo (bool val) |
Control whether a IP_PKTINFO ancillary message is received with each datagram. | |
bool | getPktInfo () const |
void | setMulticastLoop (bool val) |
Whether to set the IP_MULTICAST_LOOP socket option. | |
bool | getMulticastLoop () const |
void | setInterface (Inet4Address maddr, const Inet4NetworkInterface &iaddr) |
void | setInterface (Inet4Address iaddr) |
Inet4NetworkInterface | getInterface () const |
Inet4NetworkInterface | getInterface (const std::string &name) const |
Inet4NetworkInterface | findInterface (const Inet4Address &) const |
std::list< Inet4NetworkInterface > | getInterfaces () const |
void | setBroadcastEnable (bool val) |
Enable or disable SO_BROADCAST. | |
bool | getBroadcastEnable () const |
Protected Member Functions | |
void | getLocalAddr () |
Do system call to determine local address of this socket. | |
void | getRemoteAddr () |
Do system call to determine address of remote end. | |
Protected Attributes | |
int | _sockdomain |
int | _socktype |
SocketAddress * | _localaddr |
SocketAddress * | _remoteaddr |
int | _fd |
int | _backlog |
bool | _reuseaddr |
bool | _hasTimeout |
struct timespec | _timeout |
bool | _pktInfo |
Implementation of a socket, providing a C++ interface to system socket calls: socket,bind,listen,accept,setsockopt, etc.
This is patterned after java.net.SocketImpl. This class includes methods for both stream (TCP) and datagram (UDP) sockets. We also haven't implemented the socket implementation factory from Java.
This class provides the public copy constructors and assignment operators. Objects of this class can be copied and assigned to without restriction. However, because of this, the destructor does not close the socket file descriptor, so, in general, you should make sure that the socket is closed once at some point.
SocketImpl::SocketImpl | ( | int | domain, |
int | type ) |
IOException |
References _fd, _localaddr, _remoteaddr, _sockdomain, _socktype, nidas::util::SocketAddress::clone(), and getLocalAddr().
SocketImpl::SocketImpl | ( | int | fd, |
const SocketAddress & | remoteaddr ) |
IOException |
References getLocalAddr().
SocketImpl::SocketImpl | ( | const SocketImpl & | x | ) |
Copy constructor.
SocketImpl::~SocketImpl | ( | ) |
References _localaddr, and _remoteaddr.
Socket * SocketImpl::accept | ( | ) |
IOException |
References _fd, _localaddr, _sockdomain, _socktype, accept(), NLOG, nidas::util::SocketAddress::toAddressString(), and VLOG.
Referenced by accept(), and nidas::util::ServerSocket::accept().
void SocketImpl::bind | ( | const Inet4Address & | addr, |
int | port ) |
IOException |
void SocketImpl::bind | ( | const SocketAddress & | sockaddr | ) |
IOException |
References _fd, _reuseaddr, _sockdomain, _socktype, bind(), getLocalAddr(), listen(), and WLOG.
void SocketImpl::bind | ( | int | port | ) |
IOException |
Referenced by bind(), nidas::util::DatagramSocket::bind(), nidas::util::DatagramSocket::bind(), bind(), bind(), nidas::util::DatagramSocket::DatagramSocket(), nidas::util::DatagramSocket::DatagramSocket(), nidas::util::DatagramSocket::DatagramSocket(), nidas::util::ServerSocket::ServerSocket(), nidas::util::ServerSocket::ServerSocket(), and nidas::util::ServerSocket::ServerSocket().
void SocketImpl::close | ( | ) |
IOException |
References _fd, close(), fd, getLocalSocketAddress(), getRemoteSocketAddress(), and VLOG.
Referenced by close(), nidas::util::Socket::close(), nidas::util::ServerSocket::close(), and nidas::util::DatagramSocket::close().
void SocketImpl::connect | ( | const Inet4Address & | addr, |
int | port ) |
IOException |
void SocketImpl::connect | ( | const SocketAddress & | addr | ) |
void SocketImpl::connect | ( | const std::string & | dest, |
int | port ) |
UnknownHostException | |
IOException |
References connect(), nidas::util::Inet4Address::getByName(), and port.
Referenced by connect(), nidas::util::Socket::connect(), nidas::util::DatagramSocket::connect(), connect(), nidas::util::Socket::connect(), nidas::util::DatagramSocket::connect(), connect(), nidas::util::Socket::connect(), and nidas::util::DatagramSocket::connect().
Inet4NetworkInterface SocketImpl::findInterface | ( | const Inet4Address & | iaddr | ) | const |
IOException |
References getInterfaces().
Referenced by nidas::util::MulticastSocket::findInterface().
bool SocketImpl::getBroadcastEnable | ( | ) | const |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::DatagramSocket::getBroadcastEnable().
|
inline |
Get the domain of this socket: AF_UNIX, AF_INET, etc, from sys/socket.h.
References _sockdomain.
Referenced by nidas::util::Socket::getDomain(), nidas::util::ServerSocket::getDomain(), getInQueueSize(), getKeepAlive(), getKeepAliveIdleSecs(), getOutQueueSize(), getTcpNoDelay(), setKeepAlive(), setKeepAliveIdleSecs(), and setTcpNoDelay().
|
inline |
References _fd.
Referenced by nidas::util::Socket::getFd(), nidas::util::ServerSocket::getFd(), nidas::util::DatagramSocket::getFd(), getInterface(), getInterface(), getInterfaces(), and receive().
int SocketImpl::getInQueueSize | ( | ) | const |
Get number of bytes currently unread in the local input queue.
This does a call to ioctl(fd, SIOCINQ, &num); See man 7 tcp or udp.
IOException |
References _fd, _localaddr, getDomain(), and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::getInQueueSize().
Inet4NetworkInterface SocketImpl::getInterface | ( | ) | const |
IOException |
References _fd, _localaddr, getFd(), nidas::util::Inet4Address::getHostAddress(), getInterface(), getInterfaces(), nidas::util::SocketAddress::toAddressString(), and VLOG.
Referenced by getInterface(), nidas::util::MulticastSocket::getInterface(), getInterfaces(), and receive().
Inet4NetworkInterface SocketImpl::getInterface | ( | const std::string & | name | ) | const |
IOException |
list< Inet4NetworkInterface > SocketImpl::getInterfaces | ( | ) | const |
IOException |
References getFd(), getInterface(), and VLOG.
Referenced by findInterface(), getInterface(), nidas::util::Socket::getInterfaces(), nidas::util::DatagramSocket::getInterfaces(), nidas::util::MulticastSocket::getInterfaces(), joinGroup(), and leaveGroup().
bool SocketImpl::getKeepAlive | ( | ) | const |
Get the current value of the SO_KEEPALIVE socket option.
IOException |
References _fd, _localaddr, getDomain(), len, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::getKeepAlive(), and setKeepAliveIdleSecs().
int SocketImpl::getKeepAliveIdleSecs | ( | ) | const |
Get the current value of TCP_KEEPIDLE on this socket.
IOException |
References _fd, _localaddr, getDomain(), len, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::getKeepAliveIdleSecs().
|
protected |
Do system call to determine local address of this socket.
IOException |
References _fd, _localaddr, _sockdomain, and VLOG.
Referenced by bind(), connect(), SocketImpl(), and SocketImpl().
|
inline |
Get local port number of this socket.
)
References _localaddr, and nidas::util::SocketAddress::getPort().
Referenced by nidas::util::Socket::getLocalPort(), nidas::util::ServerSocket::getLocalPort(), and nidas::util::DatagramSocket::getLocalPort().
|
inline |
Get local socket address of this socket.
)
References _localaddr.
Referenced by close(), nidas::util::Socket::getLocalSocketAddress(), nidas::util::ServerSocket::getLocalSocketAddress(), and nidas::util::DatagramSocket::getLocalSocketAddress().
bool SocketImpl::getMulticastLoop | ( | ) | const |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
int SocketImpl::getOutQueueSize | ( | ) | const |
Get number of bytes currently unsent in the local output queue.
This does a call to ioctl(fd, SIOCOUTQ, &num); See man 7 tcp or udp.
IOException |
References _fd, _localaddr, getDomain(), and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::getOutQueueSize().
|
inline |
int SocketImpl::getReceiveBufferSize | ( | ) |
IOException |
References _fd, _localaddr, nidas::util::SocketAddress::toAddressString(), and VLOG.
Referenced by nidas::util::Socket::getReceiveBufferSize(), nidas::util::ServerSocket::getReceiveBufferSize(), and nidas::util::DatagramSocket::getReceiveBufferSize().
|
protected |
Do system call to determine address of remote end.
IOException |
References _fd, _remoteaddr, _sockdomain, and VLOG.
Referenced by connect().
|
inline |
Get remote port number of this socket.
)
References _remoteaddr, and nidas::util::SocketAddress::getPort().
Referenced by nidas::util::Socket::getRemotePort().
|
inline |
Get remote socket address of this socket.
)
References _remoteaddr.
Referenced by close(), and nidas::util::Socket::getRemoteSocketAddress().
int SocketImpl::getSendBufferSize | ( | ) |
IOException |
References _fd, _localaddr, nidas::util::SocketAddress::toAddressString(), and VLOG.
Referenced by nidas::util::Socket::getSendBufferSize(), nidas::util::ServerSocket::getSendBufferSize(), and nidas::util::DatagramSocket::getSendBufferSize().
bool SocketImpl::getTcpNoDelay | ( | ) |
Get the TCP_NODELAY (man 7 tcp) option on the socket.
IOException |
References _fd, _localaddr, getDomain(), len, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::getTcpNoDelay().
int SocketImpl::getTimeout | ( | ) | const |
References _timeout, MSECS_PER_SEC, and NSECS_PER_MSEC.
int SocketImpl::getTimeToLive | ( | ) | const |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::MulticastSocket::getMulticastLoop(), and nidas::util::MulticastSocket::getTimeToLive().
bool SocketImpl::isNonBlocking | ( | ) | const |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::isNonBlocking(), nidas::util::ServerSocket::isNonBlocking(), and nidas::util::DatagramSocket::isNonBlocking().
void SocketImpl::joinGroup | ( | Inet4Address | groupAddr | ) |
Join a multicast group on all interfaces.
IOException |
References ELOG, getInterfaces(), and joinGroup().
Referenced by joinGroup(), nidas::util::MulticastSocket::joinGroup(), and nidas::util::MulticastSocket::joinGroup().
void SocketImpl::joinGroup | ( | Inet4Address | groupAddr, |
const Inet4NetworkInterface & | iface ) |
Join a multicast group on a specific interface.
According to "man 7 ip", if the interface adddress "is equal to INADDR_ANY an appropriate interface is chosen by the system", which may not be what you want. This was eth0 on a system with lo,eth0 and eth1.
IOException |
void SocketImpl::leaveGroup | ( | Inet4Address | groupAddr | ) |
Leave a multicast group on all interfaces.
IOException |
References getInterfaces(), and leaveGroup().
Referenced by leaveGroup(), nidas::util::MulticastSocket::leaveGroup(), and nidas::util::MulticastSocket::leaveGroup().
void SocketImpl::leaveGroup | ( | Inet4Address | groupAddr, |
const Inet4NetworkInterface & | iaddr ) |
void SocketImpl::listen | ( | ) |
IOException |
References _backlog, _fd, _localaddr, _sockdomain, _socktype, listen(), and nidas::util::SocketAddress::toAddressString().
SocketImpl & SocketImpl::operator= | ( | const SocketImpl & | rhs | ) |
Assignment operator.
References _backlog, _fd, _localaddr, _pktInfo, _remoteaddr, _reuseaddr, _sockdomain, _socktype, nidas::util::SocketAddress::clone(), and setTimeout().
void SocketImpl::receive | ( | DatagramPacketBase & | packet | ) |
IOException |
References _fd, _hasTimeout, _localaddr, _timeout, ILOG, recvfrom(), and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::DatagramSocket::receive(), and nidas::util::DatagramSocket::receive().
void SocketImpl::receive | ( | DatagramPacketBase & | packet, |
Inet4PacketInfo & | info, | ||
int | flags = 0 ) |
IOException |
References _fd, _hasTimeout, _localaddr, _timeout, nidas::util::Inet4PacketInfo::getDestinationAddress(), getFd(), nidas::util::Inet4PacketInfo::getInterface(), getInterface(), nidas::util::Inet4PacketInfo::getLocalAddress(), getPktInfo(), ILOG, LOG_DEBUG, nidas::util::Inet4PacketInfo::setDestinationAddress(), nidas::util::Inet4PacketInfo::setInterface(), nidas::util::Inet4PacketInfo::setLocalAddress(), setPktInfo(), nidas::util::SocketAddress::toAddressString(), and WLOG.
size_t SocketImpl::recv | ( | void * | buf, |
size_t | len, | ||
int | flags = 0 ) |
Receive data on a socket.
See "man 2 recv" for values of the flags parameter (none of which have been tested). An EOFException is returned if the remote host does an orderly shutdown of the socket.
IOException |
References _fd, _hasTimeout, _localaddr, _timeout, ILOG, len, recv(), and nidas::util::SocketAddress::toAddressString().
Referenced by recv(), nidas::util::Socket::recv(), and nidas::util::DatagramSocket::recv().
size_t SocketImpl::recvfrom | ( | void * | buf, |
size_t | len, | ||
int | flags, | ||
SocketAddress & | from ) |
IOException |
References _fd, _hasTimeout, _localaddr, _timeout, ILOG, len, recvfrom(), and nidas::util::SocketAddress::toAddressString().
Referenced by receive(), recvfrom(), and nidas::util::DatagramSocket::recvfrom().
void SocketImpl::send | ( | const DatagramPacketBase & | packet, |
int | flags = 0 ) |
IOException |
References _fd, sendto(), and VLOG.
Referenced by nidas::util::DatagramSocket::send(), nidas::util::Socket::send(), nidas::util::DatagramSocket::send(), send(), nidas::util::DatagramSocket::send(), nidas::util::Socket::send(), and sendall().
size_t SocketImpl::send | ( | const struct iovec * | iov, |
int | iovcnt, | ||
int | flags = 0 ) |
IOException |
References _fd, _remoteaddr, and nidas::util::SocketAddress::toAddressString().
size_t SocketImpl::send | ( | const void * | buf, |
size_t | len, | ||
int | flags = 0 ) |
send data on socket.
See send UNIX man page.
buf | pointer to buffer. |
len | number of bytes to send. @flags bitwise OR of flags for send. Default: 0. |
IOException |
References _fd, _remoteaddr, len, send(), and nidas::util::SocketAddress::toAddressString().
void SocketImpl::sendall | ( | const void * | buf, |
size_t | len, | ||
int | flags = 0 ) |
send all data in buffer on socket, repeating send() as necessary, until all data is sent (or an exception occurs).
buf | pointer to buffer. |
len | number of bytes to send. @flags bitwise OR of flags for send. Default: 0. |
IOException |
References _fd, _remoteaddr, len, send(), and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::sendall().
size_t SocketImpl::sendto | ( | const struct iovec * | iov, |
int | iovcnt, | ||
int | flags, | ||
const SocketAddress & | to ) |
IOException |
References _fd, _remoteaddr, and nidas::util::SocketAddress::toAddressString().
size_t SocketImpl::sendto | ( | const void * | buf, |
size_t | len, | ||
int | flags, | ||
const SocketAddress & | to ) |
IOException |
References _fd, len, and sendto().
Referenced by send(), nidas::util::DatagramSocket::sendto(), sendto(), and nidas::util::DatagramSocket::sendto().
|
inline |
References _backlog.
Referenced by nidas::util::ServerSocket::ServerSocket(), nidas::util::ServerSocket::ServerSocket(), and nidas::util::ServerSocket::ServerSocket().
void SocketImpl::setBroadcastEnable | ( | bool | val | ) |
Enable or disable SO_BROADCAST.
Note that broadcasting is generally not advised, best to use multicast instead.
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::DatagramSocket::setBroadcastEnable().
void SocketImpl::setInterface | ( | Inet4Address | iaddr | ) |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
void SocketImpl::setInterface | ( | Inet4Address | maddr, |
const Inet4NetworkInterface & | iaddr ) |
IOException |
References _fd, _localaddr, nidas::util::SocketAddress::toAddressString(), and VLOG.
Referenced by nidas::util::MulticastSocket::setInterface(), and nidas::util::MulticastSocket::setInterface().
void SocketImpl::setKeepAlive | ( | bool | val | ) |
Set or unset the SO_KEEPALIVE socket option.
IOException |
References _fd, _localaddr, getDomain(), len, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::setKeepAlive(), and setKeepAliveIdleSecs().
void SocketImpl::setKeepAliveIdleSecs | ( | int | val | ) |
Set the number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes (TCP_KEEPIDLE).
Only appropriate for stream (TCP) connections, not datagrams (UDP). Calls setKeepAlive(true) if necessary so that the SO_KEEPALIVE option is set.
val | Number of seconds. |
IOException |
man 7 tcp: tcp_keepalive_time The number of seconds a connection needs to be idle before TCP begins send- ing out keep-alive probes. Keep-alives are only sent when the SO_KEEPALIVE socket option is enabled. The default value is 7200 seconds (2 hours). An idle connection is terminated after approximately an additional 11 minutes (9 probes an interval of 75 seconds apart) when keep-alive is enabled.
Note that underlying connection tracking mechanisms and application timeouts may be much shorter.
References _fd, _localaddr, getDomain(), getKeepAlive(), len, setKeepAlive(), and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::setKeepAliveIdleSecs().
void SocketImpl::setMulticastLoop | ( | bool | val | ) |
Whether to set the IP_MULTICAST_LOOP socket option.
According to "man 7 ip", IP_MULTICAST_LOOP controls "whether sent multicast packets should be looped back to the local sockets." This behaviour seems to be the default in Linux in that setting this does not seem to be necessary for a process on a host to receive multicast packets that are sent out on one of its interfaces, providing the multicast reader has joined that interface, and a firewall is not blocking them.
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
void SocketImpl::setNonBlocking | ( | bool | val | ) |
IOException |
References _fd, _localaddr, ILOG, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::ServerSocket::ServerSocket(), nidas::util::ServerSocket::ServerSocket(), nidas::util::ServerSocket::ServerSocket(), nidas::util::Socket::setNonBlocking(), nidas::util::ServerSocket::setNonBlocking(), and nidas::util::DatagramSocket::setNonBlocking().
void SocketImpl::setPktInfo | ( | bool | val | ) |
Control whether a IP_PKTINFO ancillary message is received with each datagram.
Only supported on DatagramSockets. The IP_PKTINFO message is converted to an Inet4PacketInfo object which is available via the getInet4PacketInfo() method.
val | if true enable the IP_PKTINFO message, if false, disable. |
IOException |
References _fd, _localaddr, _pktInfo, len, and nidas::util::SocketAddress::toAddressString().
Referenced by receive(), and nidas::util::DatagramSocket::setPktInfo().
void SocketImpl::setReceiveBufferSize | ( | int | size | ) |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::setReceiveBufferSize(), nidas::util::ServerSocket::setReceiveBufferSize(), and nidas::util::DatagramSocket::setReceiveBufferSize().
|
inline |
References _reuseaddr.
void SocketImpl::setSendBufferSize | ( | int | size | ) |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::setSendBufferSize(), nidas::util::ServerSocket::setSendBufferSize(), and nidas::util::DatagramSocket::setSendBufferSize().
void SocketImpl::setTcpNoDelay | ( | bool | val | ) |
Set the TCP_NODELAY (man 7 tcp) option on the socket.
This option is only appropriate for TCP sockets.
val | If true, set TCP_NODELAY. If false unset it. |
IOException |
References _fd, _localaddr, getDomain(), ILOG, len, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::Socket::setTcpNoDelay().
void SocketImpl::setTimeout | ( | int | val | ) |
Set the timeout for receive(), recv(), and recvfrom() methods.
val | timeout in milliseconds. 0=no timeout (infinite) The receive methods will return IOTimeoutException if an operation times out. |
References _hasTimeout, _timeout, MSECS_PER_SEC, and NSECS_PER_MSEC.
Referenced by operator=(), nidas::util::Socket::setTimeout(), and nidas::util::DatagramSocket::setTimeout().
void SocketImpl::setTimeToLive | ( | int | val | ) |
IOException |
References _fd, _localaddr, and nidas::util::SocketAddress::toAddressString().
Referenced by nidas::util::MulticastSocket::setMulticastLoop(), and nidas::util::MulticastSocket::setTimeToLive().
|
protected |
Referenced by listen(), operator=(), and setBacklog().
|
protected |
Referenced by accept(), bind(), close(), connect(), getBroadcastEnable(), getFd(), getInQueueSize(), getInterface(), getKeepAlive(), getKeepAliveIdleSecs(), getLocalAddr(), getMulticastLoop(), getOutQueueSize(), getReceiveBufferSize(), getRemoteAddr(), getSendBufferSize(), getTcpNoDelay(), getTimeToLive(), isNonBlocking(), joinGroup(), leaveGroup(), listen(), operator=(), receive(), receive(), recv(), recvfrom(), send(), send(), send(), sendall(), sendto(), sendto(), setBroadcastEnable(), setInterface(), setInterface(), setKeepAlive(), setKeepAliveIdleSecs(), setMulticastLoop(), setNonBlocking(), setPktInfo(), setReceiveBufferSize(), setSendBufferSize(), setTcpNoDelay(), setTimeToLive(), and SocketImpl().
|
protected |
Referenced by receive(), receive(), recv(), recvfrom(), and setTimeout().
|
protected |
Referenced by accept(), getBroadcastEnable(), getInQueueSize(), getInterface(), getKeepAlive(), getKeepAliveIdleSecs(), getLocalAddr(), getLocalPort(), getLocalSocketAddress(), getMulticastLoop(), getOutQueueSize(), getReceiveBufferSize(), getSendBufferSize(), getTcpNoDelay(), getTimeToLive(), isNonBlocking(), listen(), operator=(), receive(), receive(), recv(), recvfrom(), setBroadcastEnable(), setInterface(), setInterface(), setKeepAlive(), setKeepAliveIdleSecs(), setMulticastLoop(), setNonBlocking(), setPktInfo(), setReceiveBufferSize(), setSendBufferSize(), setTcpNoDelay(), setTimeToLive(), SocketImpl(), and ~SocketImpl().
|
protected |
Referenced by getPktInfo(), operator=(), and setPktInfo().
|
protected |
Referenced by getRemoteAddr(), getRemotePort(), getRemoteSocketAddress(), operator=(), send(), send(), sendall(), sendto(), SocketImpl(), and ~SocketImpl().
|
protected |
Referenced by bind(), operator=(), and setReuseAddress().
|
protected |
Referenced by accept(), bind(), connect(), getDomain(), getLocalAddr(), getRemoteAddr(), listen(), operator=(), and SocketImpl().
|
protected |
Referenced by accept(), bind(), connect(), listen(), operator=(), and SocketImpl().
|
protected |
Referenced by getTimeout(), receive(), receive(), recv(), recvfrom(), and setTimeout().