cgv
cgv::os::socket Class Reference

#include <socket.h>

Inheritance diagram for cgv::os::socket:
cgv::data::ref_counted cgv::os::socket_client cgv::os::socket_server

Public Member Functions

virtual ~socket ()
 virtual destructor
 
std::string get_last_error () const
 returns the last error
 
bool is_data_pending () const
 return whether data has arrived
 
int get_nr_of_arrived_bytes () const
 return the number of data bytes that have been arrived at the socket or -1 if socket is not connected More...
 
std::string receive_line ()
 receive data up to the next newline excluding the newline char
 
std::string receive_data (unsigned int nr_of_bytes=0)
 receive all pending data or if nr_of_bytes is larger than 0, exactly nr_of_bytes
 
bool send_line (const std::string &content)
 extends line by newline and send as data
 
bool send_data (const std::string &)
 send the data in the string
 
bool close ()
 close the socket
 
int get_ref_count () const
 read access to current count
 

Static Public Member Functions

static void enable_debug_output (bool enable=true)
 enables or disables (default) debug output for all socket commands
 

Protected Member Functions

 socket ()
 hides constructor from user
 
 socket (size_t _id)
 construct from existing socket identifier
 
bool set_last_error (const char *location, const std::string &text="") const
 convenience function to set last error and print debug info. The method always returns false.
 
void set_ref_count (int c) const
 write access is also const to allow ref counted pointers to const instances
 

Protected Attributes

size_t user_data
 store platform dependent reference to socket
 
std::string last_error
 store the last error
 

Detailed Description

base class for all sockets

Member Function Documentation

◆ get_nr_of_arrived_bytes()

int cgv::os::socket::get_nr_of_arrived_bytes ( ) const

return the number of data bytes that have been arrived at the socket or -1 if socket is not connected

return the number of data bytes that have been arrived at the socket


The documentation for this class was generated from the following files: