00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00293 basic_socket (basic_socket const&);
00294
00295
00296 basic_socket operator= (basic_socket const&);
00297
00298 descriptor_t _M_sd;
00299
00300 };
00301 }
00302
00303 #endif // SOCKETSTREAM_BASIC_SOCKET_H