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 */
tcpclient_close
void tcpclient_close(urg_tcpclient_t *cli)
destructor of tcp client module
Definition: urg_tcpclient.c:192
urg_tcpclient_t::rb
ring_buffer_t rb
Definition: urg_tcpclient.h:51
urg_ring_buffer.h
リングバッファ
urg_tcpclient_t::sock_addr_size
int sock_addr_size
Definition: urg_tcpclient.h:48
tcpclient_read
int tcpclient_read(urg_tcpclient_t *cli, char *userbuf, int req_size, int timeout)
read from socket.
Definition: urg_tcpclient.c:206
ring_buffer_t
リングバッファの管理情報
Definition: urg_ring_buffer.h:15
urg_tcpclient_t
TCP/IP connection.
Definition: urg_tcpclient.h:44
RB_SIZE
@ RB_SIZE
Definition: urg_tcpclient.h:35
tcpclient_error
int tcpclient_error(urg_tcpclient_t *cli, char *error_message, int max_size)
Definition: urg_tcpclient.c:280
tcpclient_open
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
BUFSIZE
@ BUFSIZE
Definition: urg_tcpclient.h:39
urg_tcpclient_t::pushed_back
int pushed_back
Definition: urg_tcpclient.h:55
tcpclient_readline
int tcpclient_readline(urg_tcpclient_t *cli, char *userbuf, int buf_size, int timeout)
read one line from socket.
Definition: urg_tcpclient.c:292
urg_detect_os.h
OS の検出.
urg_tcpclient_t::sock_desc
int sock_desc
Definition: urg_tcpclient.h:47
RB_BITSHIFT
@ RB_BITSHIFT
Definition: urg_tcpclient.h:34
tcpclient_write
int tcpclient_write(urg_tcpclient_t *cli, const char *userbuf, int req_size)
write to socket.
Definition: urg_tcpclient.c:273


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Wed Mar 2 2022 01:08:11