$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-18 20:54:14
Until yahoogroups gets their bug fixed, please use the files section to
transmit what you'd normally put in an attachment. I could disable
attachments, but then how would we know when YG fixes the bug?
----- Original Message -----
From:
To: <boost_at_[hidden]>
Sent: Tuesday, December 18, 2001 5:11 PM
Subject: [boost] sockets library
>
----------------------------------------------------------------------------
----
> //
> // Definitions of socket classes for boost
> //
>
> #include <string>
> #include <sstream>
>
> #ifndef boost_sockets
> #define boost_sockets
>
>
>
> //
> // Creates a client socket
> //
> class client_socket : private socket
> {
> public:
>
> client_socket ( std::string host, int port );
> virtual ~client_socket(){};
>
> const client_socket& operator << ( const std::string& ) const;
> const client_socket& operator >> ( std::string& ) const;
> const client_socket& operator << ( const marshallable& ) const;
> const client_socket& operator >> ( marshallable& ) const;
> };
>
>
>
>
> //
> // Creates a server socket
> //
> class server_socket : private socket
> {
> public:
>
> server_socket ( int port );
> server_socket (){};
> virtual ~server_socket();
>
> const server_socket& operator << ( const std::string& ) const;
> const server_socket& operator >> ( std::string& ) const;
> const server_socket& operator << ( const marshallable& ) const;
> const server_socket& operator >> ( marshallable& ) const;
>
> void accept ( server_socket& );
>
> };
>
>
>
>
> //
> // Inherit from marshallable and implement
> // marshal and unmarshal to allow your class
> // to be sent across a socket.
> //
> class marshallable
> {
> public:
> marshallable(){};
> ~marshallable(){};
>
> virtual void marshal ( std::ostringstream& );
> virtual void unmarshal ( std::istringstream& );
> };
>
>
>
>
> //
> // exception class
> //
> class socket_exception
> {
> public:
> socket_exception ( std;:string );
> ~socket_exception();
> };
>
>
>
> //
> // Most of the implementation is in here. We
> // can have a different class for each platform.
> //
> class socket
> {
>
> public:
>
> socket();
> virtual ~socket();
>
> // Server initialization
> bool create();
> bool bind ( const int port );
> bool listen() const;
> bool accept ( Socket& ) const;
>
> // Client initialization
> bool connect ( const std::string host, const int port );
>
> // Data Transimission
> bool send ( const std::string ) const;
> int recv ( std::string& ) const;
>
> bool is_valid() const { return m_sock != -1; }
>
> private:
>
> int m_sock;
> sockaddr_in m_addr;
>
> };
>
>
>
> #endif
>