Go to the documentation of this file.
45 #ifndef CCXX_SOCKET_H_
46 #define CCXX_SOCKET_H_
48 #ifndef CCXX_ADDRESS_H_
52 #if defined(WIN32) && !defined(__CYGWIN32__)
54 #define _IOLEN64 (unsigned)
55 #define _IORET64 (int)
56 #define TIMEOUT_INF ~((timeout_t) 0)
57 typedef int socklen_t;
59 #define INVALID_SOCKET -1
72 #define MSG_DONTWAIT 0
76 #define MSG_NOSIGNAL 0
83 #define IPPROTO_DCCP 33
88 #define DCCP_SOCKOPT_AVAILABLE_CCIDS 12
89 #define DCCP_SOCKOPT_CCID 13
90 #define DCCP_SOCKOPT_TX_CCID 14
91 #define DCCP_SOCKOPT_RX_CCID 15
93 #ifdef CCXX_NAMESPACES
129 typedef enum Family Family;
163 typedef enum Error Error;
172 typedef enum Tos Tos;
179 typedef enum Pending Pending;
190 typedef enum State State;
195 mutable const char *errstr;
198 void setSocket(
void);
240 inline void error(
const char *err)
const
241 {
error(errExtended, err);};
250 {flags.thrown = !enable;};
412 Socket(
int domain,
int type,
int protocol = 0);
506 {
return getIPV4Sender(port);}
524 {
return getIPV4Peer(port);}
540 {
return getIPV4Local(port);}
576 {
return getIPV4NAT(port);}
652 {
return flags.broadcast;};
660 {
return flags.route;};
723 struct sockaddr_in ipv4;
725 struct sockaddr_in6 ipv6;
887 inline Error setKeepAlive(
bool enable)
893 struct sockaddr_in6 ipv6;
894 struct sockaddr_in ipv4;
898 struct sockaddr_in ipv4;
993 ssize_t
send(
const void *buf,
size_t len);
1003 ssize_t
receive(
void *buf,
size_t len,
bool reply =
false);
1015 {
return getIPV4Peer(port);}
1028 inline ssize_t
peek(
void *buf,
size_t len)
1029 {
return _IORET64 ::recv(so, (
char *)buf,
_IOLEN64 len, MSG_PEEK);};
1058 Error setBroadcast(
bool enable)
1165 inline ssize_t
send(
const void *buf,
size_t len)
1198 inline ssize_t
transmit(
const char *buffer,
size_t len)
1310 {
return _IORET64 ::recv(so, (
char *)buf,
_IOLEN64 len, 0);};
1451 TCPSocket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
1518 void setSegmentSize(
unsigned mss);
1567 TCPV6Socket(
const char *name,
unsigned backlog = 5,
unsigned mss = 536);
1615 #pragma warning(disable:4275) // disable C4275 warning
1636 void segmentBuffering(
unsigned mss);
1726 void connect(
const char *name,
unsigned mss = 536);
1736 {
return ((std::iostream *)
this);};
1787 TCPStream(
const char *name, Family family = IPV4,
unsigned mss = 536,
bool throwflag =
false,
timeout_t timer = 0);
1819 #ifdef HAVE_SNPRINTF
1845 inline ssize_t
peek(
void *buf,
size_t len)
1846 {
return _IORET64 ::recv(so, (
char *)buf,
_IOLEN64 len, MSG_PEEK);};
1906 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
1909 tpport_t port,
size_t size = 536,
int pri = 0,
size_t stack = 0);
2087 #ifdef COMMON_STD_EXCEPTION
2088 class __EXPORT SockException :
public IOException
2095 IOException(str, systemError), _socketError(socketError) {};
2098 {
return _socketError; }
2102 #ifdef CCXX_NAMESPACES
A specialization of IPV4Address that provides address validation for multicast addresses.
Definition: address.h:635
bool thrown
Definition: socket.h:205
Error join(const IPV6Multicast &ia)
Definition: socket.h:1289
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
bool setCCID(uint8 ccid)
Set CCID DCCP.
ssize_t write(const char *bytes, size_t length, timeout_t timeout=0)
Write bytes to buffer.
u_int8_t uint8
Definition: config.h:143
Error connectError(void)
Used as a common handler for connection failure processing.
Socket(int domain, int type, int protocol=0)
An unconnected socket may be created directly on the local machine.
SimpleTCPStream(TCPSocket &server, size_t size=512)
Create a TCP stream by accepting a connection from a bound TCP socket acting as a server.
virtual ~SimpleTCPStream()
Flush and empty all buffers, and then remove the allocated buffers.
void error(const char *err) const
This service is used to throw application defined socket errors where the application specific error ...
Definition: socket.h:240
int getRxCCID()
Get RX CCID DCCP.
UDPTransmit(const IPV4Address &bind, tpport_t port=5005)
Create a UDP transmitter, bind it to a specific interface and port address so that other UDP sockets ...
TCPStream(const char *name, Family family=IPV4, unsigned mss=536, bool throwflag=false, timeout_t timer=0)
Construct a named TCP Socket connected to a remote machine.
TCPSocket(const char *name, unsigned backlog=5, unsigned mss=536)
Create a named tcp socket by service and/or interface id.
void connect(const char *name, unsigned mss=536)
Connect a TCP stream to a named destination host and port number, using getaddrinfo interface if avai...
Tos
Definition: socket.h:165
Error connect(const IPV6Host &host, tpport_t port)
void setError(bool enable)
This service is used to turn the error handler on or off for "throwing" exceptions by manipulating th...
Definition: socket.h:249
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:562
size_t getBufferSize(void) const
Return the size of the current stream buffering used.
Definition: socket.h:1853
void endStream(void)
Used to terminate the buffer space and cleanup the socket connection.
Simple TCP Stream, to be used with Common C++ Library.
Definition: socket.h:1966
DCCP sockets are used for stream based connected sessions between two sockets.
Definition: socket.h:721
@ tosReliability
Definition: socket.h:168
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1094
UDPBroadcast(const IPV4Address &ia, tpport_t port)
Create and bind a subnet broadcast socket.
Error join(const IPV6Multicast &ia)
UDPSocket(const IPV6Address &bind, tpport_t port)
Error connect(const IPV4Host &host, tpport_t port)
Associate this socket with a specified peer host.
virtual IPV6Host getIPV6Sender(tpport_t *port=NULL) const
Error setTimeToLive(char ttl)
Set time to live.
Definition: socket.h:949
TCP sockets are used for stream based connected sessions between two sockets.
Definition: socket.h:1396
bool isRouted(void) const
Return if socket routing is enabled.
Definition: socket.h:659
@ errNotConnected
Definition: socket.h:140
Error receiveBuffer(unsigned size)
Set the protocol stack network kernel receive buffer size associated with the socket.
SOCKET getTransmitter(void)
Definition: socket.h:1179
bool isInputReady(timeout_t timeout=TIMEOUT_INF)
See if input queue has data packets available.
Definition: socket.h:1318
UDPTransmit(Family family=IPV4)
Create a UDP transmitter.
TCPSession(TCPSocket &server, int pri=0, size_t stack=0)
Create a TCP socket from a bound TCP server by accepting a pending connection from that server and ex...
virtual ~TCPSession()
Make sure destruction happens through a virtual...
bool isConnected(void) const
Can test to see if this socket is "connected", and hence whether a "catch" can safely call getPeer().
bool isOutputReady(unsigned long timeout=0l)
See if output queue is empty for sending more packets.
Definition: socket.h:1207
virtual ssize_t readData(void *buf, size_t len, char separator=0, timeout_t t=0)
Read in a block of len bytes with specific separator.
int getTxCCID()
Get TX CCID DCCP.
@ errKeepaliveDenied
Definition: socket.h:151
TCPStream(const IPV6Host &host, tpport_t port, unsigned mss=536, bool throwflag=true, timeout_t timeout=0)
void disconnect(void)
Disconnect the current session and prepare for a new one.
unsigned long timeout_t
Definition: thread.h:74
void setTimeout(timeout_t timer)
Set the I/O operation timeout for socket I/O operations.
Definition: socket.h:1794
DCCPSocket(DCCPSocket &server, timeout_t timeout=0)
Create a server session by accepting a DCCP Socket.
Error disconnect(void)
Disassociate this duplex from any host connection.
@ errServiceUnavailable
Definition: socket.h:153
void disconnect(void)
Disconnect active dccp connection (client use).
SOCKET volatile so
the actual socket descriptor, in Windows, unlike posix it cannot be used as an file descriptor that w...
Definition: socket.h:221
Family family
Definition: socket.h:1644
This object is used to hold the actual and valid internet address of a specific host machine that wil...
Definition: address.h:949
SOCKET getReceiver(void) const
Definition: socket.h:1276
Error setTypeOfService(Tos tos)
Definition: socket.h:1214
SimpleTCPStream()
The constructor required for "SimpleTCPStream", a more C++ style version of the SimpleTCPStream class...
virtual ~TCPSocket()
Use base socket handler for ending this socket.
@ errNoDelay
Definition: socket.h:156
bool isPendingConnection(timeout_t timeout=TIMEOUT_INF)
Used to wait for pending connection requests.
Definition: socket.h:843
TCPSession(TCPV6Socket &server, int pri=0, size_t stack=0)
@ tosThroughput
Definition: socket.h:167
Error drop(const IPV4Multicast &ia)
Definition: socket.h:1293
void connect(TCPV6Socket &server)
void reject(void)
Used to reject the next incoming connection request.
Error receiveLimit(int limit=1)
Set thr receive limit.
size_t bufsize
Definition: socket.h:1643
int sync(void)
Flushes the stream input and output buffers, writes pending output.
Error connect(const IPV6Address &host, tpport_t port)
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
Definition: socket.h:1028
virtual ~TCPStream()
Flush and empty all buffers, and then remove the allocated buffers.
Family
Definition: socket.h:122
int underflow()
This streambuf method is used to load the input buffer through the established tcp socket connection.
int uflow()
This streambuf method is used for doing unbuffered reads through the establish tcp socket connection ...
long getSystemError(void) const
Definition: socket.h:678
DCCPSocket(const char *name, Family family=IPV4, unsigned backlog=5)
Create a named dccp socket by service and/or interface id.
TCPStream(const TCPStream &source)
A copy constructor creates a new stream buffer.
ssize_t read(char *bytes, size_t length, timeout_t timeout=0)
Read bytes into a buffer.
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:187
@ errConnectFailed
Definition: socket.h:144
void setCompletion(bool immediate)
Used to specify blocking mode for the socket.
size_t available()
Return number of bytes to be read.
void setPeer(const char *service)
Associate socket with a named connection.
TCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog=5, unsigned mss=536)
A TCP "server" is created as a TCP socket that is bound to a hardware address and port number on the ...
void reject(void)
Used to reject the next incoming connection request.
bool loopback
Definition: socket.h:209
Error setLoopback(bool enable)
Set the loopback.
Definition: socket.h:937
virtual IPV6Host getIPV6Sender(tpport_t *port=NULL) const
Socket::Error getInterfaceIndex(const char *ethX, int &InterfaceIndex)
get the interface index for a named network device
Socket::Error join(const IPV4Multicast &ia, int InterfaceIndex)
join a multicast group on a particular interface
void endTransmitter(void)
Stop transmitter.
Definition: socket.h:1171
std::iostream * tcp(void)
Used in derived classes to refer to the current object via it's iostream.
Definition: socket.h:1735
Error setRouting(bool enable)
Definition: socket.h:1279
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
bool completion
Definition: socket.h:211
void setPeer(const IPV4Broadcast &subnet, tpport_t port)
Set peer by subnet rather than specific host.
SOCKET getSocket(void)
Fetch out the socket.
Definition: socket.h:1537
IPV6Host getIPV6Peer(tpport_t *port=NULL) const
@ errInput
Definition: socket.h:135
@ errBindingFailed
Definition: socket.h:148
virtual ssize_t writeData(const void *buf, size_t len, timeout_t t=0)
Write a block of len bytes to socket.
IPV4Host getIPV4Local(tpport_t *port=NULL) const
Get the local address and port number this socket is currently bound to.
Family family
Definition: socket.h:902
void endSocket(void)
Used as the default destructor for ending a socket.
DCCPSocket(const IPV4Address &bind, tpport_t port, unsigned backlog=5)
A DCCP "server" is created as a DCCP socket that is bound to a hardware address and port number on th...
virtual ~UDPSocket()
Destroy a UDP socket as a socket.
void reject(void)
Used to reject the next incoming connection request.
Error setMulticastByFamily(bool enable, Family family=IPV4)
Setting multicast binds the multicast interface used for the socket to the interface the socket itsel...
void connect(TCPSocket &server)
Accept a connection from a TCP Server.
State volatile state
Definition: socket.h:222
unsigned ttl
Definition: socket.h:213
TCPSession(const IPV6Host &host, tpport_t port, size_t size=536, int pri=0, size_t stack=0)
@ errMulticastDisabled
Definition: socket.h:154
virtual ~Socket()
The socket base class may be "thrown" as a result of an error, and the "catcher" may then choose to d...
@ pendingInput
Definition: socket.h:175
IPV6Host getLocal(tpport_t *port=NULL) const
Used to get local bound address.
Definition: socket.h:1588
int getSegmentSize(void)
Get protocol segment size.
Error
Definition: socket.h:131
ssize_t receive(void *buf, size_t len, bool reply=false)
Receive a message from any host.
bool isPendingReceive(timeout_t timeout)
Check for pending data.
Definition: socket.h:1267
The broadcast address object is used to store the broadcast address for a specific subnet.
Definition: address.h:613
ssize_t send(const void *buf, size_t len)
Send a message packet to a peer host.
@ AVAILABLE
Definition: socket.h:184
@ errTimeout
Definition: socket.h:155
Error setKeepAlive(bool enable)
Set the keep-alive status of this socket and if keep-alive messages will be sent.
Network addresses and sockets related classes.
void connect(const char *service)
void setPeer(const IPV6Host &host, tpport_t port)
void allocate(size_t size)
Used to allocate the buffer space needed for iostream operations.
bool linger
Definition: socket.h:212
SimpleTCPStream(const IPV4Host &host, tpport_t port, size_t size=512)
Create a TCP stream by connecting to a TCP socket (on a remote machine).
Error setRouting(bool enable)
Set the socket routing to indicate if outgoing messages should bypass normal routing (set false).
static bool check(Family fam)
See if a specific protocol family is available in the current runtime environment.
@ errRoutingDenied
Definition: socket.h:150
void flush()
Definition: socket.h:2042
timeout_t timeout
Definition: socket.h:1642
IPV4Host getPeer(tpport_t *port=NULL) const
Definition: socket.h:523
TCPSession(const IPV4Host &host, tpport_t port, size_t size=536, int pri=0, size_t stack=0)
Create a TCP socket that will be connected to a remote TCP server and that will execute under it's ow...
IPV6Host getIPV6Peer(tpport_t *port=NULL) const
Error sendLimit(int limit=2048)
Set the send limit.
const char * getErrorString(void) const
Often used by a "catch" to fetch the user set error string of a thrown socket, but only if EXTENDED e...
Definition: socket.h:676
Error setRouting(bool enable)
Definition: socket.h:1211
bool keepalive
Definition: socket.h:208
IPV4Host getRequest(tpport_t *port=NULL) const
Return address and port of next connection request.
Definition: socket.h:1461
TCPStream(const IPV4Host &host, tpport_t port, unsigned mss=536, bool throwflag=true, timeout_t timeout=0)
Create a TCP stream by connecting to a TCP socket (on a remote machine).
IPV4Host getIPV4Peer(tpport_t *port=NULL) const
Examine address of sender of next waiting packet.
IPV4Host getLocal(tpport_t *port=NULL) const
Used to get local bound address.
Definition: socket.h:1472
#define MSG_DONTWAIT
Definition: socket.h:72
@ CONNECTED
Definition: socket.h:186
bool isPendingConnection(timeout_t timeout=TIMEOUT_INF)
Used to wait for pending connection requests.
Definition: socket.h:1596
virtual ~DCCPSocket()
Use base socket handler for ending this socket.
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for acce...
Definition: socket.h:1632
Error connect(const IPV4Multicast &mgroup, tpport_t port)
Associate this socket with a multicast group.
TCPStream(TCPSocket &server, bool throwflag=true, timeout_t timeout=0)
Create a TCP stream by accepting a connection from a bound TCP socket acting as a server.
Representing half of a two-way UDP connection, the UDP receiver can receive data from another peer ho...
Definition: socket.h:1230
#define __EXPORT
Definition: config.h:979
@ pendingOutput
Definition: socket.h:176
The network name and address objects are all derived from a common IPV6Address base class.
Definition: address.h:754
The Socket is used as the base for all Internet protocol services under Common C++.
Definition: socket.h:120
The network name and address objects are all derived from a common IPV4Address base class.
Definition: address.h:351
DCCPSocket(Family family=IPV4)
Create an unconnected ephemeral DCCP client socket.
IPV6Host getIPV6NAT(tpport_t *port=NULL) const
void connect(const IPV4Host &host, tpport_t port)
static Mutex mutex
Definition: socket.h:202
DCCPSocket(const IPV6Address &bind, tpport_t port, unsigned backlog=5)
int waitConnection(timeout_t timeout=TIMEOUT_INF)
Normally called during the thread Initial() method by default, this will wait for the socket connecti...
Pending
Definition: socket.h:174
IPV4Host getNAT(tpport_t *port) const
Definition: socket.h:575
Error setLoopbackByFamily(bool enable, Family family=IPV4)
Set the multicast loopback flag for the socket.
bool isPending(Pending pend, timeout_t timeout=TIMEOUT_INF)
Get the status of pending stream data.
void connect(const IPV4Host &host, tpport_t port, unsigned mss=536)
Create a TCP stream by connecting to a TCP socket (on a remote machine).
void setSegmentSize(unsigned mss)
char * pbuf
Definition: socket.h:1645
IPV4Host getSender(tpport_t *port=NULL) const
Definition: socket.h:505
Error setMulticast(bool enable)
Definition: socket.h:1282
bool operator!() const
Operator based testing to see if a socket is currently active.
Error setNoDelay(bool enable)
Enable/disable delaying packets (Nagle algorithm)
void initial(void)
The initial method is used to esablish a connection when delayed completion is used.
virtual bool isPending(Pending pend, timeout_t timeout=TIMEOUT_INF)
Get the status of pending operations.
Error drop(const IPV6Multicast &ia)
Definition: socket.h:1297
Error connect(const IPV4Host &host, tpport_t port)
Associate the duplex with a specified peer host.
@ errLookupFail
Definition: socket.h:158
bool isBroadcast(void) const
Return if broadcast has been enabled for the specified socket.
Definition: socket.h:651
@ errCopyFailed
Definition: socket.h:134
bool isPending(Pending pend, timeout_t timeout=TIMEOUT_INF)
Get the status of pending stream data.
IPV4Host getLocal(tpport_t *port=NULL) const
Definition: socket.h:539
Error sendBuffer(unsigned size)
Set the protocol stack network kernel send buffer size associated with the socket.
IPV6Host getRequest(tpport_t *port=NULL) const
Return address and port of next connection request.
Definition: socket.h:1577
ssize_t peek(char *bytes, size_t length, timeout_t timeout=0)
Peek at the incoming data.
Error getErrorNumber(void) const
Often used by a "catch" to fetch the last error of a thrown socket.
Definition: socket.h:668
void setPeer(const IPV4Host &host, tpport_t port)
set the peer address to send message packets to.
TCPStream(TCPV6Socket &server, bool throwflag=true, timeout_t timeout=0)
IPV4Host getIPV4NAT(tpport_t *port=NULL) const
Perform NAT table lookup for this socket.
virtual IPV4Host getIPV4Sender(tpport_t *port=NULL) const
May be used to examine the origin of data waiting in the socket receive queue.
virtual bool onAccept(const IPV4Host &ia, tpport_t port)
A method to call in a derived TCPSocket class that is acting as a server when a connection request is...
virtual IPV4Host getIPV4Sender(tpport_t *port=NULL) const
Error receiveTimeout(timeout_t timer)
Receive timeout for receiving raw network data.
UDPSocket(Family family=IPV4)
Create an unbound UDP socket, mostly for internal use.
@ errConnectInvalid
Definition: socket.h:145
void connect(const char *name)
Connect to a named client.
SimpleTCPStream(const SimpleTCPStream &source)
A copy constructor creates a new stream buffer.
@ BOUND
Definition: socket.h:185
int segsize
Definition: socket.h:1398
Error setMulticast(bool enable)
Definition: socket.h:1182
IPV4Host getPeer(tpport_t *port=NULL) const
Definition: socket.h:1014
UDPSocket(const IPV4Address &bind, tpport_t port)
Create a UDP socket and bind it to a specific interface and port address so that other UDP sockets on...
Error setTypeOfService(Tos service)
Set packet scheduling on platforms which support ip quality of service conventions.
Socket()
Create an inactive socket object for base constructors.
Socket & operator=(const Socket &from)
Sockets may also be duplicated by the assignment operator.
Representing half of a two-way UDP connection, the UDP transmitter can broadcast data to another sele...
Definition: socket.h:1088
void connect(const IPV4Host &host, tpport_t port, timeout_t timeout=0)
Create a DCCP client connection to a DCCP socket (on a remote machine).
@ errOutput
Definition: socket.h:138
friend SOCKET dupSocket(SOCKET s, Socket::State state)
TCPV6 sockets are used for stream based connected sessions between two ipv6 sockets.
Definition: socket.h:1515
UDP sockets implement the TCP SOCK_DGRAM UDP protocol.
Definition: socket.h:885
@ errOutputInterrupt
Definition: socket.h:139
Socket(const Socket &source)
A socket can also be constructed from an already existing Socket object.
class __EXPORT SimpleTCPStream
Definition: socket.h:1952
SOCKET getSocket(void)
Fetch out the socket.
Definition: socket.h:1418
Error connect(const IPV4Broadcast &subnet, tpport_t port)
Associate this socket with a subnet of peer hosts for subnet broadcasting.
@ tosMinCost
Definition: socket.h:169
virtual bool onAccept(const IPV6Host &ia, tpport_t port)
Error join(const IPV4Multicast &ia)
Definition: socket.h:1285
Socket(SOCKET fd)
A socket object may be created from a file descriptor when that descriptor was created either through...
bool multicast
Definition: socket.h:210
int getSegmentSize(void)
Definition: socket.h:1540
friend TCPStream & crlf(TCPStream &)
@ errConnectNoRoute
Definition: socket.h:147
int SOCKET
Definition: socket.h:60
Error error(Error error, const char *err=NULL, long systemError=0) const
This service is used to throw all socket errors which usually occur during the socket constructor.
State
Definition: socket.h:182
void connect(const IPV6Host &host, tpport_t port, unsigned mss=536)
virtual bool onAccept(const IPV4Host &ia, tpport_t port)
A method to call in a derived DCCPSocket class that is acting as a server when a connection request i...
Error setTimeToLive(unsigned char ttl)
Definition: socket.h:1185
ssize_t transmit(const char *buffer, size_t len)
Transmit "send" to use "connected" send rather than sendto.
Definition: socket.h:1198
@ INITIAL
Definition: socket.h:183
Error join(const IPV4Multicast &ia)
Join a multicast group.
void endStream(void)
Used to terminate the buffer space and cleanup the socket connection.
IPV6Host getIPV6Local(tpport_t *port=NULL) const
The TCP session is used to primarily to represent a client connection that can be managed on a sepera...
Definition: socket.h:1868
ssize_t readLine(char *buf, size_t len, timeout_t timeout=0)
Process a logical input line from a socket descriptor directly.
Error sendTimeout(timeout_t timer)
Set the send timeout for sending raw network data.
Error setBroadcast(bool enable)
Definition: socket.h:1217
ssize_t send(const void *buf, size_t len)
Transmit "send" to use "connected" send rather than sendto.
Definition: socket.h:1165
Error setLinger(bool linger)
Enable lingering sockets on close.
Error connect(const IPV4Host &host, tpport_t port)
Associate this socket with a specified peer host.
void endReceiver(void)
End receiver.
Definition: socket.h:1273
A specialization of IPV6Address that provides address validation for multicast addresses.
Definition: address.h:1011
@ errExtended
Definition: socket.h:157
#define _IOLEN64
Definition: socket.h:64
size_t printf(const char *format,...)
Print content into a socket.
@ errServiceDenied
Definition: socket.h:152
void connect(const IPV6Host &host, tpport_t port)
bool route
Definition: socket.h:207
Representing a UDP socket used for subnet broadcasts, this class provides an alternate binding and se...
Definition: socket.h:1054
@ errConnectBusy
Definition: socket.h:146
Error setMulticast(bool enable)
Set the multicast.
Definition: socket.h:943
UDPTransmit(const IPV6Address &bind, tpport_t port=5005)
Error setTimeToLiveByFamily(unsigned char ttl, Family fam=IPV4)
Set the multicast time to live for a multicast socket.
@ errCreateFailed
Definition: socket.h:133
Error connect(const IPV6Host &host, tpport_t port)
#define MSG_NOSIGNAL
Definition: socket.h:76
UDP duplex connections impliment a bi-directional point-to-point UDP session between two peer hosts.
Definition: socket.h:1333
UDPDuplex(const IPV6Address &bind, tpport_t port)
IPV4Host getIPV4Peer(tpport_t *port=NULL) const
Get the host address and port of the socket this socket is connected to.
Error connect(const IPV6Multicast &mgroup, tpport_t port)
Error bufferSize(unsigned size)
Set the total protocol stack network kernel buffer size for both send and receive together.
Error drop(const IPV4Multicast &ia)
Drop membership from a multicast group.
bool isPendingConnection(timeout_t timeout=TIMEOUT_INF)
Used to wait for pending connection requests.
Definition: socket.h:1480
@ errConnectTimeout
Definition: socket.h:143
void connect(const IPV6Host &host, tpport_t port, timeout_t timeout=0)
int getSegmentSize(void)
Get the buffer size for servers.
Definition: socket.h:1424
UDPSocket(const char *name, Family family=IPV4)
Create a UDP socket bound by a service name.
bool broadcast
Definition: socket.h:206
@ CONNECTING
Definition: socket.h:187
UDPDuplex(const IPV4Address &bind, tpport_t port)
Create a UDP duplex as a pair of UDP simplex objects bound to alternating and interconnected port add...
Error drop(const IPV6Multicast &ia)
bool isActive(void) const
Test to see if the socket is at least operating or if it is mearly initialized.
virtual ~TCPV6Socket()
Use base socket handler for ending this socket.
virtual bool onAccept(const IPV6Host &ia, tpport_t port)
A method to call in a derived TCPSocket class that is acting as a server when a connection request is...
ssize_t peek(void *buf, size_t len)
Examine contents of next waiting packet.
Definition: socket.h:1845
This is a generic and portable string class.
Definition: string.h:81
@ errConnectRefused
Definition: socket.h:141
ssize_t receive(void *buf, size_t len)
Receive a data packet from the connected peer host.
Definition: socket.h:1309
@ errSearchErr
Definition: socket.h:159
@ errConnectRejected
Definition: socket.h:142
Error setBroadcast(bool enable)
Set the subnet broadcast flag for the socket.
UDPReceive(const IPV4Address &bind, tpport_t port)
Create a UDP receiver, bind it to a specific interface and port address so that other UDP sockets on ...
int overflow(int ch)
This streambuf method is used to write the output buffer through the established tcp connection.
friend TCPStream & lfcr(TCPStream &)
TCPV6Socket(const char *name, unsigned backlog=5, unsigned mss=536)
Create a TCP server for a named host interface and service port.
UDPReceive(const IPV6Address &bind, tpport_t port)
@ errInputInterrupt
Definition: socket.h:136
const char * getSystemErrorString(void) const
#define TIMEOUT_INF
Definition: thread.h:115
TCPV6Socket(const IPV6Address &bind, tpport_t port, unsigned backlog=5, unsigned mss=536)
A TCP "server" is created as a TCP socket that is bound to a hardware address and port number on the ...
TCPStream(Family family=IPV4, bool throwflag=true, timeout_t to=0)
The constructor required for building other classes or to start an unconnected TCPStream for connect.
void Connect(const IPV4Host &host, tpport_t port, size_t size)
Create a TCP stream by connecting to a TCP socket (on a remote machine).
@ errBroadcastDenied
Definition: socket.h:149
@ errResourceFailure
Definition: socket.h:137