simple-socket library 1.1.5

SCTPSocket.h

Go to the documentation of this file.
00001 #ifndef NET_SCTPSocket_h__
00002 #define NET_SCTPSocket_h__
00003 
00004 #include "SocketHandle.h"
00005 #include "InternetSocket.h"
00006 
00007 #include <netinet/in.h>
00008 #include <netinet/sctp.h>
00009 
00010 #include <vector>
00011 #include <string>
00012 
00013 namespace NET
00014 {
00016     class SCTPSocket : public InternetSocket
00017     {
00018     public:
00020         typedef SocketHandle<SCTPSocket> Handle;
00021 
00022         enum abortFlag
00023         {
00024             ABORT = SCTP_ABORT,
00025             SHUTDOWN = SCTP_EOF,
00026             KEEPALIVE = 0
00027         };
00028 
00029         enum switchAddressFlag
00030         {
00031             KEEP_PRIMARY = 0,
00032             OVERRIDE_PRIMARY = SCTP_ADDR_OVER
00033         };
00034 
00035         enum receiveFlag
00036         {
00037         };
00038 
00039         SCTPSocket( unsigned numOutStreams = 10, unsigned maxInStreams = 65535, unsigned maxAttempts = 4,
00040                     unsigned maxInitTimeout = 0 /* TODO */);
00041 
00046         SCTPSocket( Handle handle);
00047 
00048         using InternetSocket::bind;
00049         int bind( const std::vector<std::string>& localAddresses, unsigned short localPort = 0);
00050 
00051         using InternetSocket::connect;
00052         int connect( const std::vector<std::string>& foreignAddresses, unsigned short foreignPort = 0);
00053 
00054         int state() const;
00055         int notAckedData() const;
00056         int pendingData() const;
00057         unsigned inStreams() const;
00058         unsigned outStreams() const;
00059         unsigned fragmentationPoint() const;
00060         std::string primaryAddress() const;
00061 
00062         using SimpleSocket::send;
00063         int send( const void* data, int length, unsigned stream, unsigned ttl = 0, unsigned context = 0, unsigned ppid = 0,
00064                   abortFlag abort = KEEPALIVE, switchAddressFlag switchAddr = KEEP_PRIMARY);
00065 
00066         int sendUnordered( const void* data, int length, unsigned stream, unsigned ttl = 0, unsigned context = 0,
00067                            unsigned ppid = 0, abortFlag abort = KEEPALIVE, switchAddressFlag switchAddr = KEEP_PRIMARY);
00068 
00069         using SimpleSocket::receive;
00070         int receive( void* data, int maxLen, unsigned& stream);
00071         int receive( void* data, int maxLen, unsigned& stream, receiveFlag& flag);
00072 
00073         using SimpleSocket::timedReceive;
00074         int timedReceive( void* data, int maxLen, unsigned& stream, unsigned timeout);
00075         int timedReceive( void* data, int maxLen, unsigned& stream, receiveFlag& flag, unsigned timeout);
00076 
00077         void listen( int backlog = 5);
00078         Handle accept() const;
00079         Handle timedAccept( unsigned timeout) const;
00080 
00081     protected:
00082         void setInitValues( unsigned ostr, unsigned istr, unsigned att, unsigned time);
00083     };
00084 
00085 } // namespace NET
00086 
00087 #endif // NET_SCTPSocket_h__