00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SOCKETS_SctpSocket_H
00024 #define _SOCKETS_SctpSocket_H
00025 #include "sockets-config.h"
00026
00027 #include <map>
00028 #include "Socket.h"
00029 #ifdef USE_SCTP
00030 #include <netinet/sctp.h>
00031
00032 #ifdef SOCKETS_NAMESPACE
00033 namespace SOCKETS_NAMESPACE {
00034 #endif
00035
00036 #define SCTP_BUFSIZE_READ 16400
00037
00038 class SocketAddress;
00039
00040
00041 class SctpSocket : public Socket
00042 {
00043 public:
00047 SctpSocket(ISocketHandler& h,int type);
00048 ~SctpSocket();
00049
00051 int Bind(const std::string&,port_t);
00052 int Bind(SocketAddress&);
00054 int AddAddress(const std::string&,port_t);
00055 int AddAddress(SocketAddress&);
00057 int RemoveAddress(const std::string&,port_t);
00058 int RemoveAddress(SocketAddress&);
00059
00061 int Open(const std::string&,port_t);
00062 int Open(SocketAddress&);
00064 int AddConnection(const std::string&,port_t);
00065 int AddConnection(SocketAddress&);
00066
00068 int getpaddrs(sctp_assoc_t id,std::list<std::string>&);
00070 int getladdrs(sctp_assoc_t id,std::list<std::string>&);
00071
00073 int PeelOff(sctp_assoc_t id);
00074
00076 virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
00077
00078 void OnOptions(int,int,int,SOCKET) {}
00079
00080 protected:
00081 void OnRead();
00082 void OnWrite();
00083
00084 private:
00085 int m_type;
00086 char *m_buf;
00087 };
00088
00089
00090 #ifdef SOCKETS_NAMESPACE
00091 }
00092 #endif
00093
00094 #endif // USE_SCTP
00095 #endif // _SOCKETS_SctpSocket_H