|
| Handle | accept () const |
| |
| int | bind (const std::vector< std::string > &localAddresses, unsigned short localPort=0) |
| |
| void | bind (std::string_view localAddress, unsigned short localPort=0) |
| | bind socket to address / port
|
| |
| void | bind (unsigned short localPort=0) |
| |
| int | connect (const std::vector< std::string > &foreignAddresses, unsigned short foreignPort=0) |
| |
| void | connect (std::string_view foreignAddress, unsigned short foreignPort) |
| | establish a connection with the given foreign address and port
|
| |
| void | disconnect () |
| | Disconnect and unset any foreign addresses.
|
| |
| unsigned | fragmentationPoint () const |
| |
| std::string | getForeignAddress () const |
| |
| unsigned short | getForeignPort () const |
| |
| std::string | getLocalAddress () const |
| |
| unsigned short | getLocalPort () const |
| |
| unsigned | inStreams () const |
| |
| void | listen (int backlog=5) |
| |
| int | nativeHandle () |
| | return the native handle of the open socket
|
| |
| int | notAckedData () const |
| |
| unsigned | outStreams () const |
| |
| bool | peerDisconnected () const |
| | returns whether a peer disconnected
|
| |
| int | pendingData () const |
| |
| std::string | primaryAddress () const |
| |
| int | receive (void *buffer, size_t len) |
| | receive data from a bound socket
|
| |
| int | receive (void *data, size_t maxLen, uint16_t &stream) |
| |
| int | receive (void *data, size_t maxLen, uint16_t &stream, receiveFlag &flag) |
| |
| | SCTPSocket (Handle handle) |
| |
| | SCTPSocket (uint16_t numOutStreams=10, uint16_t maxInStreams=65535, uint16_t maxAttempts=4, uint16_t maxInitTimeout=0) |
| |
| int | send (const void *buffer, size_t len) |
| | send data through a connected socket
|
| |
| int | send (const void *data, size_t length, uint16_t stream, unsigned ttl=0, unsigned context=0, unsigned ppid=0, abortFlag abort=KEEPALIVE, switchAddressFlag switchAddr=KEEP_PRIMARY) |
| |
| int | sendUnordered (const void *data, size_t length, uint16_t stream, unsigned ttl=0, unsigned context=0, unsigned ppid=0, abortFlag abort=KEEPALIVE, switchAddressFlag switchAddr=KEEP_PRIMARY) |
| |
| void | shutdown (ShutdownDirection type) |
| | shutdown the connection in the specified direction
|
| |
| int | state () const |
| |
| Handle | timedAccept (int timeout) const |
| |
| int | timedConnect (std::string_view foreignAddress, unsigned short foreignPort, int timeout) |
| | establish a connection with the given foreign address and port
|
| |
| int | timedReceive (void *buffer, size_t len, int timeout) |
| | receive data from a bound socket, return after the given timespan
|
| |
| int | timedReceive (void *data, size_t maxLen, uint16_t &stream, int timeout) |
| |
| int | timedReceive (void *data, size_t maxLen, uint16_t &stream, receiveFlag &flag, int timeout) |
| |
SCTP socket class.
Definition at line 16 of file SCTPSocket.h.
| void InternetSocket::bind |
( |
std::string_view | localAddress, |
|
|
unsigned short | localPort = 0 ) |
bind socket to address / port
Set the local port to the specified port and the local address to an interface.
bind() attaches the local endpoint of the socket to the specified interface and port. Typically all servers use bind() to attach to the local port specified by the used protocol. You just need to call bind if you want to restrict the connection to a specific local interface, or if you want to listen on a specific port. If you are just a client using connect() to connect to a server, calling bind is most likely unnecessary.
To bind to a port < 1023 you need eighter superuser access, or the SUID bit set on your program.
- Parameters
-
| localAddress | local address |
| localPort | local port |
- Exceptions
-
Definition at line 74 of file InternetSocket.cpp.
| void InternetSocket::connect |
( |
std::string_view | foreignAddress, |
|
|
unsigned short | foreignPort ) |
establish a connection with the given foreign address and port
If you are using a connection oriented socket (like TCPSocket), you have to call connect() on that socket in order to send data. However, if you are using a non-connection oriented socket (like UDPSocket), calling connect on that socket will allow you to use the send() function like on a connection oriented socket. If not connected, you would have to use sendTo
- Parameters
-
| foreignAddress | foreign address (IP address or name) |
| foreignPort | foreign port |
- Exceptions
-
Definition at line 34 of file InternetSocket.cpp.
| int SimpleSocket::send |
( |
const void * | buffer, |
|
|
size_t | len ) |
send data through a connected socket
send() can only be used on a socket that called connect() before. If you try to use send() on a not connected socket, SocketException will be thrown.
If you are using a stream oriented socket (like TCPSocket), the operating system is allowed to send only a part of the packet you told it to send, so send() will return the number of bytes actually sent. It is your responsibility to resend the data not sent by send()
If you are using a datagram oriented socket (like UDPSocket or SCTPSocket) the operating system will only send and receive complete datagrams, but send() will fail if you are trying to send too much data. In that case SocketException will be thrown.
- Parameters
-
| buffer | data to be send |
| len | length of the data to be sent |
- Returns
- number of bytes sent
- Exceptions
-
Definition at line 84 of file SimpleSocket.cpp.
| int SimpleSocket::receive |
( |
void * | buffer, |
|
|
size_t | len ) |
receive data from a bound socket
receive() can only be used on a socket that called bind() or connect() before. If you try to use receive() on a not bound socket, SocketException will be thrown.
If using a stream oriented Socket, receive can return a part of a received messge, e.g. if you send 100 bytes, it's possible you will receive 50 bytes two times in a row. However, the order of the sent data will be preserved.
If you are using a datagram oriented sockets, you will only receive whole datagrams. But beware of using a too small buffer. If the receive buffer is too small for the received datagram, the data you didn't read in the receive call will be discared.
If the remote host has closed the connection (on a connection based socket like TCP or SCTP) receive() will return 0. If you are using a connectionless protocol (like UDP) there is no way to determine wheter the connection has been closed by the remote host or not.
- Parameters
-
| buffer | the buffer the received data will be written to |
| len | length of the provided buffer, receive will not read more than that |
- Returns
- number of bytes received
- Exceptions
-
Definition at line 110 of file SimpleSocket.cpp.
| int SimpleSocket::timedReceive |
( |
void * | buffer, |
|
|
size_t | len, |
|
|
int | timeout ) |
receive data from a bound socket, return after the given timespan
timedReceive() can only be used on a socket that called bind() or connect before. If you try to use receive() on a not bound socket, SocketException will be thrown.
If using a stream oriented Socket, receive can return a part of a received messge, e.g. if you send 100 bytes, it's possible you will receive 50 bytes two times in a row. However, the order of the sent data will be preserved.
If you are using a datagram oriented sockets, you will only receive whole datagrams. But beware of using a too small buffer. If the receive buffer is too small for the received datagram, the data you didn't read in the receive call will be discared.
If the remote host has closed the connection (on a connection based socket like TCP or SCTP) receive() will return 0. If you are using a connectionless protocol (like UDP) there is no way to determine wheter the connection has been closed by the remote host or not.
- Parameters
-
| buffer | the buffer the received data will be written to |
| len | length of the provided buffer, receive will not read more than that |
| timeout | the timeout in ms after which receive will give up and return |
- Returns
- number of bytes received, 0 on timeout
- Exceptions
-
Definition at line 137 of file SimpleSocket.cpp.
| void SimpleSocket::disconnect |
( |
| ) |
|
|
inherited |
Disconnect and unset any foreign addresses.
This will ungracefully abort the connection by sending an RST frame. disconnect() should not be used under normal circumstances, as it will terminate the connection OOB, preventing the other end of the communication from retrieving data that would still be available in the OS buffer.
For normal termination of a connection use shutdown().
- Exceptions
-
Definition at line 93 of file SimpleSocket.cpp.
shutdown the connection in the specified direction
This will gracefully end a connection by sending a FIN frame. Use this to end a normal communication cycle. To abort a connection see disconnect().
Depending on the specified ShutdownDirection, calls for that direction will stop working. Use this function if you want to have more control than just destroing the socket. It allows you to cut the connection in one direction, or both.
If you use shutdown() on an unconnected socket, the corresponding calls will simply stop working.
- Parameters
-
- Exceptions
-
Definition at line 108 of file SimpleSocket.cpp.