claw::net::basic_socket Class Reference

Common interface for claw::net::basic_socketbuf and claw::net::socket_server. More...

#include <basic_socket.hpp>

Inheritance diagram for claw::net::basic_socket:
claw::net::basic_socketbuf< CharT, Traits > claw::net::socket_server

List of all members.

Public Member Functions

 basic_socket ()
 Constructor.
basic_socketopen ()
 Open the socket.
basic_socketclose ()
 Close the socket.
bool is_open () const
 Tell if the socket is open.

Protected Attributes

socket_traits::descriptor m_descriptor
 File descriptor.

Detailed Description

Common interface for claw::net::basic_socketbuf and claw::net::socket_server.

Author:
Julien Jorge

Definition at line 46 of file basic_socket.hpp.


Constructor & Destructor Documentation

claw::net::basic_socket::basic_socket (  ) 

Constructor.

Postcondition:
is_open() == false

Definition at line 37 of file basic_socket.cpp.

00038   : m_descriptor(socket_traits::invalid_socket)
00039 {
00040 
00041 } // basic_socket::basic_socket()


Member Function Documentation

claw::net::basic_socket::basic_socket * claw::net::basic_socket::close (  ) 

Close the socket.

Returns:
this if everything works fine, NULL otherwise.

Reimplemented in claw::net::basic_socketbuf< CharT, Traits >, claw::net::socket_server, and claw::net::basic_socketbuf< char_type, traits_type >.

Definition at line 65 of file basic_socket.cpp.

References claw::socket_traits_unix::close(), claw::socket_traits_unix::invalid_socket, is_open(), and m_descriptor.

Referenced by claw::net::basic_socketbuf< CharT, Traits >::close(), and claw::net::socket_server::close().

00066 {
00067   basic_socket* result = this;
00068 
00069   if ( is_open() )
00070     {
00071       if ( socket_traits::close(m_descriptor) )
00072         m_descriptor = socket_traits::invalid_socket;
00073       else
00074         result = NULL;
00075     }
00076 
00077   return result;
00078 } // basic_socket::close()

bool claw::net::basic_socket::is_open (  )  const

Tell if the socket is open.

Reimplemented in claw::net::basic_socketbuf< CharT, Traits >, claw::net::socket_server, and claw::net::basic_socketbuf< char_type, traits_type >.

Definition at line 84 of file basic_socket.cpp.

References m_descriptor, and claw::socket_traits_unix::valid_descriptor().

Referenced by close().

00085 {
00086   return socket_traits::valid_descriptor(m_descriptor);
00087 } // basic_socket::is_open()

claw::net::basic_socket::basic_socket * claw::net::basic_socket::open (  ) 

Open the socket.

Returns:
this is everything works fine, NULL otherwise.

Definition at line 48 of file basic_socket.cpp.

References m_descriptor, and claw::socket_traits_unix::valid_descriptor().

Referenced by claw::net::basic_socketbuf< CharT, Traits >::open(), claw::net::socket_server::open(), and claw::net::socket_server::socket_server().

00049 {
00050   basic_socket* result = NULL;
00051   
00052   m_descriptor = socket_traits::open();
00053 
00054   if ( socket_traits::valid_descriptor( m_descriptor ) )
00055     result = this;
00056 
00057   return result;
00058 } // basic_socket::open()


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1