simple-socket library 1.9.0
Loading...
Searching...
No Matches
SCTPSocket.h
Go to the documentation of this file.
1#ifndef NET_SCTPSocket_h__
2#define NET_SCTPSocket_h__
3
4#include "InternetSocket.h"
5
6#include <netinet/in.h>
7#include <netinet/sctp.h>
8#include <vector>
9#include <optional>
10
11namespace NET
12{
15 {
16 public:
18 {
19 ABORT = SCTP_ABORT,
20 SHUTDOWN = SCTP_EOF,
22 };
23
25 {
27 OVERRIDE_PRIMARY = SCTP_ADDR_OVER
28 };
29
31 {
32 };
33
34 SCTPSocket( uint16_t numOutStreams = 10, uint16_t maxInStreams = 65535, uint16_t maxAttempts = 4,
35 uint16_t maxInitTimeout = 0 /* TODO */);
36
37 int bind( const std::vector<std::string>& localAddresses, unsigned short localPort = 0);
38
39 int connect( const std::vector<std::string>& foreignAddresses, unsigned short foreignPort = 0);
40
41 int state() const;
42 int notAckedData() const;
43 int pendingData() const;
44 unsigned inStreams() const;
45 unsigned outStreams() const;
46 unsigned fragmentationPoint() const;
47 std::string primaryAddress() const;
48
50 IOResult send( const void* data, size_t length, uint16_t stream, unsigned ttl = 0, unsigned context = 0, unsigned ppid = 0,
52
53 IOResult sendUnordered( const void* data, size_t length, uint16_t stream, unsigned ttl = 0, unsigned context = 0,
54 unsigned ppid = 0, abortFlag abort = KEEPALIVE, switchAddressFlag switchAddr = KEEP_PRIMARY);
55
56 IOResult receive( void* data, size_t maxLen, uint16_t& stream);
57 IOResult receive( void* data, size_t maxLen, uint16_t& stream, receiveFlag& flag);
58
59 IOResult timedReceive( void* data, size_t maxLen, uint16_t& stream, int timeout);
60 IOResult timedReceive( void* data, size_t maxLen, uint16_t& stream, receiveFlag& flag, int timeout);
61
62 // Listen for incoming connections
64
65 // Complete async connect attempt
67
68 std::optional<SCTPSocket> accept() const;
69 std::optional<SCTPSocket> timedAccept( int timeout) const;
70
71 protected:
72 void setInitValues( uint16_t ostr, uint16_t istr, uint16_t att, uint16_t time);
73
74 // allow construction by accept()
76 };
77
78} // namespace NET
79
80#endif // NET_SCTPSocket_h__
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
int state() const
std::optional< SCTPSocket > timedAccept(int timeout) const
std::optional< SCTPSocket > accept() const
InternetSocket(AddressFamily family, int type, int protocol)
allows a subclass to create new socket
int notAckedData() const
IOResult 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)
IOResult 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 setInitValues(uint16_t ostr, uint16_t istr, uint16_t att, uint16_t time)
std::string primaryAddress() const
IOResult timedReceive(void *data, size_t maxLen, uint16_t &stream, int timeout)
SCTPSocket(uint16_t numOutStreams=10, uint16_t maxInStreams=65535, uint16_t maxAttempts=4, uint16_t maxInitTimeout=0)
IOResult timedReceive(void *data, size_t maxLen, uint16_t &stream, receiveFlag &flag, int timeout)
IOResult receive(void *data, size_t maxLen, uint16_t &stream, receiveFlag &flag)
unsigned outStreams() const
int bind(const std::vector< std::string > &localAddresses, unsigned short localPort=0)
int connect(const std::vector< std::string > &foreignAddresses, unsigned short foreignPort=0)
unsigned fragmentationPoint() const
IOResult receive(void *data, size_t maxLen, uint16_t &stream)
int pendingData() const
unsigned inStreams() const
IOResult send(const void *buffer, size_t len)
send data through a connected socket
void listen(int backlog=128)
listen for incoming connections
ConnectResult finishConnect(int timeout=0)
check if a previously started connected attempt is finished