Component index
Section index | Component TCPCONNECT |
Search |
Type | Object |
Summary | Manage a single client TCP session |
Description | It establish the connection, calls its init functag when successful and process the data received line by line. Supports both TCP and Unix domain sockets |
int close () | ![]() ![]() | void end (TCPCONNECT &info) |
int connect () | ![]() ![]() | void fail (TCPCONNECT_INFO &info) |
bool is_ok () | ![]() ![]() | void init (bool &end, TCPCONNECT_INFO &info) |
int loop (int timeout) | ![]() ![]() | void oneline (const char *line, bool &end, TCPCONNECT_INFO &info) |
int poll () | ![]() ![]() | void time_out (bool &end, TCPCONNECT &info) |
int reconnect () | ![]() ![]() | |
int send (const char *str) | ![]() ![]() | |
int send (const void *buf, int len) | ![]() ![]() | |
int sendf (const char *ctl, ...) | ![]() ![]() | |
void set_timeout (int seconds) | ![]() ![]() | |
bool setrawmode (bool mode) | ![]() ![]() |
If the host is "unix:", the port is the unix domain socket path.
Return -1 if any error. The end functag will be called.
This method is seldom used as TCPCONNECT handle it all by itself.
This function will end only when the session ends.
The input is process and the function returns immediatly. It returns -1 if any error, 0 otherwise.
Return -1 if it failed
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
At connect time, a timeout leads to the fail functag. Later, the time_out functag is called and the application decides if it wants to end the session.
You generally used this to send the first request and do various initialisation.
This assumes that the protocol is line oriented (ASCII). In raw mode (binary) the info.linelen field may be used to learn how many bytes are pointed by the "line" pointer.
No message was received for some time. The timeout is specified as an argument of the tcpconnect function.
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
Return the number of bytes sent or -1 if any error. This method may trigger the end() functag if the server has closed the connection.
At connect time, a timeout leads to the fail functag. Later, the time_out functag is called and the application decides if it wants to end the session.
At connect time, a timeout leads to the fail functag. Later, the time_out functag is called and the application decides if it wants to end the session.
By default the object assumes line oriented protocol.
Normally, the OS sends packets only when the transmit buffer is full, after some delay, or when the program waits for the other side. This is efficient network wise. Sometime you expect the data to leave immediatly (when you call send()). This helper lets you set the flag to on or off. It is off by default