|
Kyoto Tycoon
|
Network stream abstraction based on TCP/IP. More...
#include <ktsocket.h>
Public Member Functions | |
| Socket () | |
| Default constructor. | |
| ~Socket () | |
| Destructor. | |
| const char * | error () |
| Get the last happened error information. | |
| bool | open (const std::string &expr) |
| Open a client socket. | |
| bool | close (bool grace=true) |
| Close the socket. | |
| bool | send (const void *buf, size_t size) |
| Send data. | |
| bool | send (const std::string &str) |
| Send data. | |
| bool | printf (const char *format,...) |
| Send formatted data. | |
| bool | vprintf (const char *format, va_list ap) |
| Send formatted data. | |
| bool | receive (void *buf, size_t size) |
| Receive data. | |
| int32_t | receive_byte () |
| Receive one byte. | |
| bool | undo_receive_byte (int32_t c) |
| Push one byte back. | |
| bool | receive_line (void *buf, size_t max) |
| Receive one line of characters. | |
| size_t | left_size () |
| Get the size of left data in the receiving buffer. | |
| bool | abort () |
| Abort the current operation. | |
| bool | set_timeout (double timeout) |
| Set the timeout of each operation. | |
| const std::string | expression () |
| Get the expression of the socket. | |
| int32_t | descriptor () |
| Get the descriptor integer. | |
| void | set_event_flags (uint32_t flags) |
| Set event flags. | |
| uint32_t | event_flags () |
| Get the current event flags. | |
Static Public Member Functions | |
| static std::string | get_local_host_name () |
| Get the primary name of the local host. | |
| static std::string | get_host_address (const std::string &name) |
| Get the address of a host. | |
Friends | |
| class | ServerSocket |
Network stream abstraction based on TCP/IP.
| kyototycoon::Socket::Socket | ( | ) | [explicit] |
Default constructor.
Destructor.
| const char* kyototycoon::Socket::error | ( | ) |
Get the last happened error information.
| bool kyototycoon::Socket::open | ( | const std::string & | expr | ) |
Open a client socket.
| expr | an expression of the address and the port of the server. |
| bool kyototycoon::Socket::close | ( | bool | grace = true | ) |
Close the socket.
| grace | true for graceful shutdown, or false for immediate disconnection. |
| bool kyototycoon::Socket::send | ( | const void * | buf, |
| size_t | size | ||
| ) |
Send data.
| buf | the pointer to a data region to send. |
| size | the size of the data region. |
| bool kyototycoon::Socket::send | ( | const std::string & | str | ) |
Send data.
| str | a string to send. |
| bool kyototycoon::Socket::printf | ( | const char * | format, |
| ... | |||
| ) |
Send formatted data.
| format | the printf-like format string. The conversion character `' can be used with such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `'. |
| ... | used according to the format string. |
| bool kyototycoon::Socket::vprintf | ( | const char * | format, |
| va_list | ap | ||
| ) |
Send formatted data.
| format | the printf-like format string. The conversion character `' can be used with such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `'. |
| ap | used according to the format string. |
| bool kyototycoon::Socket::receive | ( | void * | buf, |
| size_t | size | ||
| ) |
Receive data.
| buf | the pointer to the buffer into which the received data is written. |
| size | the size of the data to receive. |
| int32_t kyototycoon::Socket::receive_byte | ( | ) |
Receive one byte.
| bool kyototycoon::Socket::undo_receive_byte | ( | int32_t | c | ) |
Push one byte back.
| c | specifies the byte. |
| bool kyototycoon::Socket::receive_line | ( | void * | buf, |
| size_t | max | ||
| ) |
Receive one line of characters.
| buf | the pointer to the buffer into which the received data is written. |
| max | the maximum size of the data to receive. It must be more than 0. |
| size_t kyototycoon::Socket::left_size | ( | ) |
Get the size of left data in the receiving buffer.
| bool kyototycoon::Socket::abort | ( | ) |
Abort the current operation.
| bool kyototycoon::Socket::set_timeout | ( | double | timeout | ) |
Set the timeout of each operation.
| timeout | the timeout of each operation in seconds. |
| const std::string kyototycoon::Socket::expression | ( | ) |
Get the expression of the socket.
| int32_t kyototycoon::Socket::descriptor | ( | ) | [virtual] |
Get the descriptor integer.
Implements kyototycoon::Pollable.
| void kyototycoon::Socket::set_event_flags | ( | uint32_t | flags | ) | [virtual] |
Set event flags.
| flags | specifies the event mode. The following may be added by bitwise-or: Socket::EVINPUT for input events, Socket::EVOUTPUT for output events, Socket::EVEXCEPT for exception events. |
Implements kyototycoon::Pollable.
| uint32_t kyototycoon::Socket::event_flags | ( | ) | [virtual] |
| static std::string kyototycoon::Socket::get_local_host_name | ( | ) | [static] |
Get the primary name of the local host.
| static std::string kyototycoon::Socket::get_host_address | ( | const std::string & | name | ) | [static] |
Get the address of a host.
1.7.6.1