Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

sslserversocket.h

Go to the documentation of this file.
00001 #ifndef SSLSERVERSOCKET_H
00002 #define SSLSERVERSOCKET_H
00003 
00004 // $Id: sslserversocket.h,v 1.5 2002/10/19 10:36:49 dvermeir Exp $
00005 
00006 #include        <stdexcept>
00007 #include        <dvssl/sslcontext.h>
00008 #include        <dvssl/sslsocket.h>
00009 #include        <dvnet/serversocket.h>
00010 /* \file
00011    This file defines the Dv::Ssl::SslServerSocket class.
00012 */
00013 
00014 namespace Dv {
00015 namespace Ssl {
00016 
00017 //! A class derived from Dv::Ssl::ServerSocket that uses SSL.
00018 /*! Example usage:
00019     \code
00020     try {
00021       SslContextV23     context("key.pem","cert.pem");
00022       SslServerSocket   server(context,port);
00023 
00024       cerr << "SSL echo server started.." << endl;
00025       ref<SslSocket>    client(server.accept());
00026 
00027       string line;
00028       while (getline(*client,line))
00029         *client << line << endl;
00030       cout << "client status: " << client->strerror() << endl;
00031       return server.error();
00032       }
00033     catch (exception& e) {
00034       cerr << e.what() << endl;
00035       return 2;
00036       }
00037     \endcode
00038 */
00039 class SslServerSocket: public Net::ServerSocket {
00040 public:
00041 
00042   //! Constructor.
00043   /*! The Dv::Ssl::SslContext parameter must contain both a 
00044       key file and a certificate file.
00045   */
00046   SslServerSocket(SslContext& context,int port,int backlog = 10) 
00047                                                 throw (std::runtime_error);
00048   //! Accept a connection from an SSL client.
00049   /*! Delay and bufsz are used for the resulting SslSocket.
00050       \param delay number of millisecs resulting socket will wait for I/O
00051       \param bufsz buffer size of streambuf associated with resulting socket
00052 
00053       Note that this is different from the use of the <code>delay</code>
00054       parameter for the userversocket::accept() function.
00055   */
00056   ref<SslSocket>        accept(time_t delay = 0, size_t bufsz=1024 );
00057 private:
00058   SslContext&   context_;
00059 };
00060 
00061 }}
00062 #endif
00063 

dvssl-0.5.4 [19 September, 2003]