| version 1.12, 2003/07/16 16:09:16 |
version 1.13, 2006/08/14 10:03:21 |
|
|
| * |
* |
| * @file platon/net/connection.h |
* @file platon/net/connection.h |
| * @author Ondrej Jombik <nepto@platon.sk> |
* @author Ondrej Jombik <nepto@platon.sk> |
| * @version \$Platon: libplaton/platon/net/connection.h,v 1.11 2003/04/23 19:28:36 nepto Exp $ |
* @version \$Platon: libplaton/platon/net/connection.h,v 1.12 2003/07/16 16:09:16 nepto Exp $ |
| * @date 2000-2003 |
* @date 2000-2003 |
| */ |
*/ |
| |
|
| #ifndef _PLATON_NET_CONNECTION_H |
#ifndef _PLATON_NET_CONNECTION_H |
| #define _PLATON_NET_CONNECTION_H |
#define _PLATON_NET_CONNECTION_H |
| |
|
| /** End of line string. */ |
|
| #ifndef NET_CONNECTION_EOL |
|
| # define NET_CONNECTION_EOL "\r\n" |
|
| #endif |
|
| |
|
| /** Default port (telnet) */ |
|
| #ifndef NET_CONNECTION_PORT |
|
| # define NET_CONNECTION_PORT 23 |
|
| #endif |
|
| |
|
| /** Stream mode */ |
|
| #ifndef NET_CONNECTION_FMODE |
|
| # define NET_CONNECTION_FMODE "rt+" |
|
| #endif |
|
| |
|
| /** |
|
| * Performs stream-oriented connection to remote host |
|
| * |
|
| * @param host hostname |
|
| * @param port port |
|
| * @return connection stream (FILE *) |
|
| * |
|
| * Note that ouput stream will be buffered. |
|
| */ |
|
| #define net_connection_fconnect(host,port) \ |
|
| fdopen(net_connection_connect(host,port), NET_CONNECTION_FMODE) |
|
| |
|
| #ifdef __cplusplus |
#ifdef __cplusplus |
| extern "C" { |
extern "C" { |
| #endif |
#endif |
|
|
| * @param port port |
* @param port port |
| * @return connection handle (socket) or -1 on error |
* @return connection handle (socket) or -1 on error |
| */ |
*/ |
| int net_connection_connect(const char*host,int port); |
int net_connection_open(const char *host, int port); |
| |
void net_connection_close(int *handle); |
| |
|
| /** |
/** |
| * Read data from connection |
* Read data from connection |
|
|
| * @param size buffer size |
* @param size buffer size |
| * @return count of read bytes or negative value on connection lost |
* @return count of read bytes or negative value on connection lost |
| */ |
*/ |
| int net_connection_read(int handle,char*buffer,int size); |
int net_connection_read(int *handle, void *buffer, int size); |
| |
int net_connection_read_blocked(int *handle, void *buffer, int size); |
| |
int net_connection_read_full(int *handle, void *buffer, int size); |
| |
|
| |
#if 0 |
| /** |
/** |
| * Read one line from connection |
* Read one line from connection |
| * |
* |
|
|
| * |
* |
| * One line is character set terminated with @ref NET_CONNECTION_EOL. |
* One line is character set terminated with @ref NET_CONNECTION_EOL. |
| */ |
*/ |
| int net_connection_gets(int handle,char*buffer,int size); |
int net_connection_gets(int *handle, char *buffer, int size); |
| |
int net_connection_gets_blocked(int *handle, char *buffer, int size); |
| |
#endif |
| |
|
| #ifdef __cplusplus |
#ifdef __cplusplus |
| } |
} |