urg_tcpclient.h
Go to the documentation of this file.
1 #ifndef URG_TCPCLIENT_H
2 #define URG_TCPCLIENT_H
3 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #include "urg_c/urg_ring_buffer.h"
18 #include "urg_c/urg_detect_os.h"
19 #include <sys/types.h>
20 #if defined(URG_WINDOWS_OS)
21 #include <windows.h>
22 #else
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
26 #endif
27 
28 
29 // -- NOT INTERFACE, for internal use only --
30 // For urg_ringbuffer.h
31 // The size of buffer must be specified by the power of 2
32 // i.e. ring buffer size = two to the RB_BITSHIFT-th power.
33 enum {
36 
37  // caution ! available buffer size is less than the
38  // size given to the ring buffer(RB_SIZE).
40 };
41 
42 
44 typedef struct {
45  // socket
46  struct sockaddr_in server_addr;
47  int sock_desc;
49 
50  // buffer
52  char buf[RB_SIZE];
53 
54  // line reading functions
55  int pushed_back; // for pushded back char
56 
58 // -- end of NON INTERFACE definitions --
59 
60 
61 // -- belows are MODULE INTERFACES --
72 extern int tcpclient_open(urg_tcpclient_t* cli,
73  const char* server_ip_str, int port_num);
74 
75 
81 extern void tcpclient_close(urg_tcpclient_t* cli);
82 
83 
94 extern int tcpclient_read(urg_tcpclient_t* cli,
95  char* userbuf, int req_size, int timeout);
96 
97 
107 extern int tcpclient_write(urg_tcpclient_t* cli,
108  const char* userbuf, int req_size);
109 
110 
112 extern int tcpclient_error(urg_tcpclient_t* cli,
113  char* error_message, int max_size);
114 
115 
126 extern int tcpclient_readline(urg_tcpclient_t* cli,
127  char* userbuf, int buf_size, int timeout);
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* !URG_TCPCLIENT_H */
OS の検出.
リングバッファ
int tcpclient_readline(urg_tcpclient_t *cli, char *userbuf, int buf_size, int timeout)
read one line from socket.
int tcpclient_write(urg_tcpclient_t *cli, const char *userbuf, int req_size)
write to socket.
TCP/IP connection.
Definition: urg_tcpclient.h:44
void tcpclient_close(urg_tcpclient_t *cli)
destructor of tcp client module
ring_buffer_t rb
Definition: urg_tcpclient.h:51
リングバッファの管理情報
int tcpclient_read(urg_tcpclient_t *cli, char *userbuf, int req_size, int timeout)
read from socket.
int tcpclient_open(urg_tcpclient_t *cli, const char *server_ip_str, int port_num)
constructor of tcp client module
Definition: urg_tcpclient.c:67
int tcpclient_error(urg_tcpclient_t *cli, char *error_message, int max_size)


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Thu Jun 6 2019 19:27:49