12 #ifndef MFEM_SOCKETSTREAM
13 #define MFEM_SOCKETSTREAM
15 #include "../config/config.hpp"
19 #ifdef MFEM_USE_GNUTLS
20 #include <gnutls/gnutls.h>
21 #if GNUTLS_VERSION_NUMBER < 0x020800
22 #error "MFEM requires GnuTLS version >= 2.8.0"
25 #define MFEM_USE_GNUTLS_X509
58 virtual int attach(
int sd);
62 virtual int open(
const char hostname[],
int port);
77 virtual int_type
overflow(int_type c = traits_type::eof());
79 virtual std::streamsize
xsgetn(char_type *__s, std::streamsize __n);
81 virtual std::streamsize
xsputn(
const char_type *__s, std::streamsize __n);
85 #ifdef MFEM_USE_GNUTLS
95 bool good()
const {
return (
res == GNUTLS_E_SUCCESS); }
103 if (
good()) {
return; }
104 mfem::out <<
"Error in " << msg <<
": " << gnutls_strerror(
res)
124 {
if (
status.
good()) { gnutls_global_set_log_level(level); } }
144 const char *pubkey_file,
145 const char *privkey_file,
146 const char *trustedkeys_file,
182 virtual int attach(
int sd);
184 virtual int open(
const char hostname[],
int port);
196 virtual std::streamsize
xsgetn(char_type *__s, std::streamsize __n);
198 virtual std::streamsize
xsputn(
const char_type *__s, std::streamsize __n);
201 #endif // MFEM_USE_GNUTLS
211 #ifdef MFEM_USE_GNUTLS
221 #ifdef MFEM_USE_GNUTLS
251 #ifdef MFEM_USE_GNUTLS
258 int open(
const char hostname[],
int port);
276 bool good() {
return (listen_socket >= 0); }
void set_result(int result)
static GnuTLS_session_params * params
virtual int attach(int sd)
socketstream(socketbuf *buf)
Create a socket stream associated with the given socket buffer. The new object takes ownership of 'bu...
virtual int_type underflow()
static int num_glvis_sockets
gnutls_certificate_credentials_t my_cred
virtual std::streamsize xsgetn(char_type *__s, std::streamsize __n)
void check_secure_socket()
GnuTLS_session_params(GnuTLS_global_state &state, const char *pubkey_file, const char *privkey_file, const char *trustedkeys_file, unsigned int flags)
int getsocketdescriptor()
gnutls_certificate_credentials_t my_cred
void set_socket(bool secure)
gnutls_dh_params_t get_dh_params()
virtual ~GnuTLS_socketbuf()
socketstream(const char hostname[], int port, bool secure=secure_default)
Create a socket stream and connect to the given host and port. The treatment of the 'secure' flag is ...
gnutls_dh_params_t dh_params
virtual int open(const char hostname[], int port)
socketstream(bool secure=secure_default)
Create a socket stream without connecting to a host.
virtual int_type underflow()
gnutls_certificate_credentials_t get_cred() const
void set_secure_socket(const GnuTLS_session_params &p)
static GnuTLS_session_params & add_socket()
virtual int_type overflow(int_type c=traits_type::eof())
virtual int attach(int sd)
GnuTLS_socketbuf(const GnuTLS_session_params &p)
void print_on_error(const char *msg) const
virtual std::streamsize xsgetn(char_type *__s, std::streamsize __n)
GnuTLS_global_state & state
virtual std::streamsize xsputn(const char_type *__s, std::streamsize __n)
virtual std::streamsize xsputn(const char_type *__s, std::streamsize __n)
virtual int open(const char hostname[], int port)
socketserver(int port, int backlog=4)
socketbuf(const char hostname[], int port)
int open(const char hostname[], int port)
static void remove_socket()
void generate_dh_params()
const GnuTLS_session_params & params
unsigned int get_flags() const
static const bool secure_default
static GnuTLS_global_state * state
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void set_log_level(int level)