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);
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__);
92 #ifdef MFEM_USE_GNUTLS
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__);
208 #endif // MFEM_USE_GNUTLS
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 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
bool is_open()
Returns true if the socket is open and has a valid socket descriptor. Otherwise returns false...
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()
Returns the attached socket descriptor.
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 ...
int close()
Close the socketstream.
gnutls_dh_params_t dh_params
virtual std::streamsize xsgetn(char_type *s__, std::streamsize n__)
virtual std::streamsize xsputn(const char_type *s__, std::streamsize n__)
virtual int close()
Close the current socket descriptor.
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...
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())
bool is_open()
True if the socketstream is open, false otherwise.
double p(const Vector &x, double t)
virtual int attach(int sd)
Attach a new socket descriptor to the socketbuf. Returns the old socket descriptor which is NOT close...
GnuTLS_socketbuf(const GnuTLS_session_params &p)
virtual std::streamsize xsgetn(char_type *s__, std::streamsize n__)
void print_on_error(const char *msg) const
GnuTLS_global_state & state
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)
socketbuf(const char hostname[], int port)
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
static void remove_socket()
virtual int close()
Close the current socket descriptor.
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...
int detach()
Detach the current socket descriptor from the socketbuf.
virtual std::streamsize xsputn(const char_type *s__, std::streamsize n__)
void set_log_level(int level)