Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

basic_socket.h

Go to the documentation of this file.
00001 // -*- Socket Streams -*-
00002 
00003 // Copyright (C) 2003, 2004, 2005 Pedro LamarĂ£o <pedro.lamarao@mndfck.org>
00004 
00005 // This file is part of the Socket Streams Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the
00008 // Free Software Foundation; either version 2.1 of the License
00009 // or (at your option) any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU Lesser General Public License for more details.
00015 
00016 // You should have received a copy of the GNU Lesser General Public License along
00017 // with this library; see the file COPYING. If not, write to the Free
00018 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
00019 // USA
00020 
00025 #ifndef SOCKETSTREAM_BASIC_SOCKET_H
00026 #define SOCKETSTREAM_BASIC_SOCKET_H 1
00027 
00028 #include <socketstream/config.h>
00029 
00030 #include <socketstream/sockets_base.h>
00031 #include <socketstream/socket_exception.h>
00032 
00033 namespace ss {
00057   class SOCKETSTREAM_API basic_socket
00058   {
00059   public:
00060 
00066     typedef sockets_base::socket_type descriptor_t;
00067     
00068     template <typename _CharT, typename _TraitsT>
00069     friend class basic_socketbuf;
00070 
00079     basic_socket ();
00080 
00094     basic_socket (int __family, int __style, int __protocol = 0);
00095 
00109     basic_socket (descriptor_t __sd);
00110 
00114     ~basic_socket ();
00115 
00125     void
00126     bind (sockaddr const* __addr, socklen_t __size);
00127 
00138     void
00139     connect (sockaddr const* __addr, socklen_t __size);
00140 
00151     void
00152     listen (int __backlog = 5);
00153 
00162     descriptor_t
00163     accept ();
00164 
00174     int
00175     receive (char* __s, size_t __n, int __flags = 0);
00176 
00190     int
00191     receive (char* __s, size_t __n,
00192              sockaddr* __addr, socklen_t* __size,
00193              int __flags = 0);
00194 
00204     int
00205     send (const char* __s, size_t __n, int __flags = 0);
00206 
00220     int
00221     send (const char* __s, size_t __n,
00222           sockaddr const* __addr, socklen_t __size,
00223           int __flags = 0);
00224 
00235     void
00236     set_option (int __level, int __option,
00237                 char const* __value, socklen_t __size);
00238 
00249     void
00250     get_option (int __level, int __option,
00251                 char* __value, socklen_t* __size) const;
00252 
00260     void
00261     shutdown (int __mode = sockets_base::rw);
00262     
00269     void
00270     peer_address (sockaddr* __name, socklen_t* __size) const;
00271     
00278     void
00279     socket_address (sockaddr* __name, socklen_t* __size) const;
00280 
00286     descriptor_t
00287     descriptor () const
00288     { return _M_sd; }    
00289 
00290   private:
00291 
00292     // Not CopyConstructible.
00293     basic_socket (basic_socket const&);
00294 
00295     // Not Assignable.
00296     basic_socket operator= (basic_socket const&);
00297 
00298     descriptor_t  _M_sd;
00299 
00300   };
00301 }
00302 
00303 #endif  // SOCKETSTREAM_BASIC_SOCKET_H

Generated on Sat May 21 21:25:32 2005 for Socket Streams Library by  doxygen 1.4.3