00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _SOCKETS_SctpSocket_H
00034 #define _SOCKETS_SctpSocket_H
00035 #include "sockets-config.h"
00036
00037 #include "StreamSocket.h"
00038 #ifdef USE_SCTP
00039 #include <netinet/sctp.h>
00040
00041 #ifdef SOCKETS_NAMESPACE
00042 namespace SOCKETS_NAMESPACE {
00043 #endif
00044
00045 #define SCTP_BUFSIZE_READ 16400
00046
00047 class SocketAddress;
00048
00049
00050 class SctpSocket : public StreamSocket
00051 {
00052 public:
00056 SctpSocket(ISocketHandler& h,int type);
00057 ~SctpSocket();
00058
00060 int Bind(const std::string&,port_t);
00061 int Bind(SocketAddress&);
00063 int AddAddress(const std::string&,port_t);
00064 int AddAddress(SocketAddress&);
00066 int RemoveAddress(const std::string&,port_t);
00067 int RemoveAddress(SocketAddress&);
00068
00070 int Open(const std::string&,port_t);
00071 int Open(SocketAddress&);
00072
00074 void OnConnectTimeout();
00075 #ifdef _WIN32
00076
00077 void OnException();
00078 #endif
00079
00080 #ifndef SOLARIS
00081
00082 int AddConnection(const std::string&,port_t);
00083 int AddConnection(SocketAddress&);
00084 #endif
00085
00087 int getpaddrs(sctp_assoc_t id,std::list<std::string>&);
00089 int getladdrs(sctp_assoc_t id,std::list<std::string>&);
00090
00092 int PeelOff(sctp_assoc_t id);
00093
00095 virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
00096
00097 void OnOptions(int,int,int,SOCKET) {}
00098
00099 virtual int Protocol();
00100
00101 protected:
00102 SctpSocket(const SctpSocket& s) : StreamSocket(s) {}
00103 void OnRead();
00104 void OnWrite();
00105
00106 private:
00107 SctpSocket& operator=(const SctpSocket& s) { return *this; }
00108 int m_type;
00109 char *m_buf;
00110 };
00111
00112
00113 #ifdef SOCKETS_NAMESPACE
00114 }
00115 #endif
00116
00117 #endif // USE_SCTP
00118 #endif // _SOCKETS_SctpSocket_H
00119