Logo
~Sockets~
~Examples~
~Contact~


SctpSocket.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2007  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 } // namespace SOCKETS_NAMESPACE
00106 #endif
00107 
00108 #endif // USE_SCTP
00109 #endif // _SOCKETS_SctpSocket_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4