|
cgv
|
client socket More...
#include <socket.h>
Public Member Functions | |
| bool | connect (const std::string &host, int port) |
| connect to given port of given host, if the socket is already connected, close this connection first | |
Public Member Functions inherited from cgv::os::socket | |
| 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 | |
| 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 | |
Public Member Functions inherited from cgv::data::ref_counted | |
| int | get_ref_count () const |
| read access to current count | |
Protected Member Functions | |
| socket_client () | |
| hide from direct use | |
Protected Member Functions inherited from cgv::os::socket | |
| 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. | |
Protected Member Functions inherited from cgv::data::ref_counted | |
| ref_counted () | |
| constructor initializes the count to 0 | |
| void | set_ref_count (int c) const |
| write access is also const to allow ref counted pointers to const instances | |
Friends | |
| CGV_API socket_client_ptr | create_socket_client () |
| this is the only way to create a socket_client as a reference counted pointer | |
Additional Inherited Members | |
Static Public Member Functions inherited from cgv::os::socket | |
| static void | enable_debug_output (bool enable=true) |
| enables or disables (default) debug output for all socket commands | |
Static Protected Member Functions inherited from cgv::os::socket | |
| static bool | begin () |
| static void | end () |
Protected Attributes inherited from cgv::os::socket | |
| size_t | user_data |
| store platform dependent reference to socket | |
| std::string | last_error |
| store the last error | |
Static Protected Attributes inherited from cgv::os::socket | |
| static bool | show_debug_output = false |
| static int | nr_of_sockets = 0 |
|
protected |
hide from direct use
Definition at line 267 of file socket.cxx.
| bool cgv::os::socket_client::connect | ( | const std::string & | host, |
| int | port | ||
| ) |
connect to given port of given host, if the socket is already connected, close this connection first
Definition at line 271 of file socket.cxx.
References connect(), cgv::os::mutex::lock(), cgv::os::socket::set_last_error(), cgv::os::socket::socket(), cgv::os::mutex::unlock(), and cgv::os::socket::user_data.
Referenced by connect().
|
friend |
this is the only way to create a socket_client as a reference counted pointer
Definition at line 299 of file socket.cxx.