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 "StreamSocket.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 StreamSocket
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&);
00063
00065 void OnConnectTimeout();
00066 #ifdef _WIN32
00067
00068 void OnException();
00069 #endif
00070
00071 #ifndef SOLARIS
00072
00073 int AddConnection(const std::string&,port_t);
00074 int AddConnection(SocketAddress&);
00075 #endif
00076
00078 int getpaddrs(sctp_assoc_t id,std::list<std::string>&);
00080 int getladdrs(sctp_assoc_t id,std::list<std::string>&);
00081
00083 int PeelOff(sctp_assoc_t id);
00084
00086 virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
00087
00088 void OnOptions(int,int,int,SOCKET) {}
00089
00090 virtual int Protocol();
00091
00092 protected:
00093 SctpSocket(const SctpSocket& s) : StreamSocket(s) {}
00094 void OnRead();
00095 void OnWrite();
00096
00097 private:
00098 SctpSocket& operator=(const SctpSocket& s) { return *this; }
00099 int m_type;
00100 char *m_buf;
00101 };
00102
00103
00104 #ifdef SOCKETS_NAMESPACE
00105 }
00106 #endif
00107
00108 #endif // USE_SCTP
00109 #endif // _SOCKETS_SctpSocket_H