12 #ifndef MFEM_SOCKETSTREAM
13 #define MFEM_SOCKETSTREAM
15 #include "../config/config.hpp"
16 #include "../general/error.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"
56 virtual int attach(
int sd);
60 virtual int open(
const char hostname[],
int port);
75 virtual int_type
overflow(int_type c = traits_type::eof());
77 virtual std::streamsize
xsgetn(char_type *__s, std::streamsize __n);
79 virtual std::streamsize
xsputn(
const char_type *__s, std::streamsize __n);
83 #ifdef MFEM_USE_GNUTLS
93 bool good()
const {
return (
res == GNUTLS_E_SUCCESS); }
101 if (
good()) {
return; }
102 std::cout <<
"Error in " << msg <<
": " << gnutls_strerror(
res)
122 {
if (
status.
good()) { gnutls_global_set_log_level(level); } }
142 const char *pubkey_file,
143 const char *privkey_file,
144 const char *trustedkeys_file,
180 virtual int attach(
int sd);
182 virtual int open(
const char hostname[],
int port);
194 virtual std::streamsize
xsgetn(char_type *__s, std::streamsize __n);
196 virtual std::streamsize
xsputn(
const char_type *__s, std::streamsize __n);
199 #endif // MFEM_USE_GNUTLS
209 #ifdef MFEM_USE_GNUTLS
219 #ifdef MFEM_USE_GNUTLS
249 #ifdef MFEM_USE_GNUTLS
256 int open(
const char hostname[],
int port);
274 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)
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
void set_log_level(int level)