simple-socket library 1.2.0
SCTPSocket.h
Go to the documentation of this file.
1#ifndef NET_SCTPSocket_h__
2#define NET_SCTPSocket_h__
3
4#include "SocketHandle.h"
5#include "InternetSocket.h"
6
7#include <netinet/in.h>
8#include <netinet/sctp.h>
9
10#include <vector>
11#include <string>
12
13namespace NET
14{
17 {
18 public:
21
23 {
24 ABORT = SCTP_ABORT,
25 SHUTDOWN = SCTP_EOF,
27 };
28
30 {
32 OVERRIDE_PRIMARY = SCTP_ADDR_OVER
33 };
34
36 {
37 };
38
39 SCTPSocket( uint16_t numOutStreams = 10, uint16_t maxInStreams = 65535, uint16_t maxAttempts = 4,
40 uint16_t maxInitTimeout = 0 /* TODO */);
41
46 SCTPSocket( Handle handle);
47
49 int bind( const std::vector<std::string>& localAddresses, unsigned short localPort = 0);
50
52 int connect( const std::vector<std::string>& foreignAddresses, unsigned short foreignPort = 0);
53
54 int state() const;
55 int notAckedData() const;
56 int pendingData() const;
57 unsigned inStreams() const;
58 unsigned outStreams() const;
59 unsigned fragmentationPoint() const;
60 std::string primaryAddress() const;
61
63 int send( const void* data, size_t length, uint16_t stream, unsigned ttl = 0, unsigned context = 0, unsigned ppid = 0,
65
66 int sendUnordered( const void* data, size_t length, uint16_t stream, unsigned ttl = 0, unsigned context = 0,
67 unsigned ppid = 0, abortFlag abort = KEEPALIVE, switchAddressFlag switchAddr = KEEP_PRIMARY);
68
70 int receive( void* data, size_t maxLen, uint16_t& stream);
71 int receive( void* data, size_t maxLen, uint16_t& stream, receiveFlag& flag);
72
74 int timedReceive( void* data, size_t maxLen, uint16_t& stream, int timeout);
75 int timedReceive( void* data, size_t maxLen, uint16_t& stream, receiveFlag& flag, int timeout);
76
77 void listen( int backlog = 5);
78 Handle accept() const;
79 Handle timedAccept( int timeout) const;
80
81 protected:
82 void setInitValues( uint16_t ostr, uint16_t istr, uint16_t att, uint16_t time);
83 };
84
85} // namespace NET
86
87#endif // NET_SCTPSocket_h__
Definition CANFrame.h:7
void bind(unsigned short localPort=0)
InternetSocket(int sockfd)
create socket from a SocketHandle returned by an accept() call
void connect(std::string_view foreignAddress, unsigned short foreignPort)
establish a connection with the given foreign address and port
unsigned outStreams() const
int notAckedData() const
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)
SCTPSocket(uint16_t numOutStreams=10, uint16_t maxInStreams=65535, uint16_t maxAttempts=4, uint16_t maxInitTimeout=0)
unsigned fragmentationPoint() const
void setInitValues(uint16_t ostr, uint16_t istr, uint16_t att, uint16_t time)
Handle accept() const
int connect(const std::vector< std::string > &foreignAddresses, unsigned short foreignPort=0)
int state() const
unsigned inStreams() const
Handle timedAccept(int timeout) const
int pendingData() const
SocketHandle< SCTPSocket > Handle
Handle for a new socket returned by accept.
Definition SCTPSocket.h:20
int receive(void *data, size_t maxLen, uint16_t &stream)
void listen(int backlog=5)
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 timedReceive(void *data, size_t maxLen, uint16_t &stream, int timeout)
int bind(const std::vector< std::string > &localAddresses, unsigned short localPort=0)
std::string primaryAddress() const
int timedReceive(void *buffer, size_t len, int timeout)
receive data from a bound socket, return after the given timespan
int send(const void *buffer, size_t len)
send data through a connected socket
int receive(void *buffer, size_t len)
receive data from a bound socket
A simple class to provide strict ownership of socket handles.