12#ifndef MFEM_SOCKETSTREAM
13#define MFEM_SOCKETSTREAM
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);
65 virtual int open(
const char hostname[],
int port);
84 virtual int_type
overflow(int_type c = traits_type::eof());
86 virtual std::streamsize
xsgetn(char_type *s__, std::streamsize n__);
88 virtual std::streamsize
xsputn(
const char_type *s__, std::streamsize n__);
102 bool good()
const {
return (
res == GNUTLS_E_SUCCESS); }
110 if (
good()) {
return; }
111 mfem::out <<
"Error in " << msg <<
": " << gnutls_strerror(
res)
131 {
if (
status.
good()) { gnutls_global_set_log_level(level); } }
151 const char *pubkey_file,
152 const char *privkey_file,
153 const char *trustedkeys_file,
189 virtual int attach(
int sd);
191 virtual int open(
const char hostname[],
int port);
203 virtual std::streamsize
xsgetn(char_type *s__, std::streamsize n__);
205 virtual std::streamsize
xsputn(
const char_type *s__, std::streamsize n__);
218#ifdef MFEM_USE_GNUTLS
228#ifdef MFEM_USE_GNUTLS
258#ifdef MFEM_USE_GNUTLS
266 int open(
const char hostname[],
int port);
286 bool good() {
return (listen_socket >= 0); }
void generate_dh_params()
void set_log_level(int level)
gnutls_dh_params_t get_dh_params()
gnutls_dh_params_t dh_params
unsigned int get_flags() const
GnuTLS_global_state & state
GnuTLS_session_params(GnuTLS_global_state &state, const char *pubkey_file, const char *privkey_file, const char *trustedkeys_file, unsigned int flags)
gnutls_certificate_credentials_t my_cred
gnutls_certificate_credentials_t get_cred() const
GnuTLS_socketbuf(const GnuTLS_session_params &p)
virtual int close()
Close the current socket descriptor.
virtual std::streamsize xsgetn(char_type *s__, std::streamsize n__)
virtual int attach(int sd)
gnutls_certificate_credentials_t my_cred
virtual int_type underflow()
virtual std::streamsize xsputn(const char_type *s__, std::streamsize n__)
virtual int open(const char hostname[], int port)
Open a socket on the 'port' at 'hostname' and store the socket descriptor. Returns 0 if there is no e...
virtual ~GnuTLS_socketbuf()
const GnuTLS_session_params & params
void set_result(int result)
void print_on_error(const char *msg) const
virtual int attach(int sd)
Attach a new socket descriptor to the socketbuf. Returns the old socket descriptor which is NOT close...
virtual int_type overflow(int_type c=traits_type::eof())
int detach()
Detach the current socket descriptor from the socketbuf.
virtual std::streamsize xsputn(const char_type *s__, std::streamsize n__)
virtual int close()
Close the current socket descriptor.
virtual int_type underflow()
virtual std::streamsize xsgetn(char_type *s__, std::streamsize n__)
bool is_open()
Returns true if the socket is open and has a valid socket descriptor. Otherwise returns false.
int getsocketdescriptor()
Returns the attached socket descriptor.
socketbuf(const char hostname[], int port)
virtual int open(const char hostname[], int port)
Open a socket on the 'port' at 'hostname' and store the socket descriptor. Returns 0 if there is no e...
socketserver(int port, int backlog=4)
void set_secure_socket(const GnuTLS_session_params &p)
void set_socket(bool secure)
static const bool secure_default
static GnuTLS_session_params * params
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 ...
socketstream(bool secure=secure_default)
Create a socket stream without connecting to a host.
static int num_glvis_sockets
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
int close()
Close the socketstream.
static GnuTLS_session_params & add_socket()
static GnuTLS_global_state * state
static void remove_socket()
bool is_open()
True if the socketstream is open, false otherwise.
socketstream(socketbuf *buf)
Create a socket stream associated with the given socket buffer. The new object takes ownership of 'bu...
void check_secure_socket()
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
real_t p(const Vector &x, real_t t)