Main Page
Related Pages
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
include
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_ring_buffer.h
"
18
#include "
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
{
34
RB_BITSHIFT = 8,
35
RB_SIZE = 1 << RB_BITSHIFT,
36
37
// caution ! available buffer size is less than the
38
// size given to the ring buffer(RB_SIZE).
39
BUFSIZE = RB_SIZE - 1,
40
};
41
42
44
typedef
struct
{
45
// socket
46
struct
sockaddr_in server_addr;
47
int
sock_desc;
48
int
sock_addr_size;
49
50
// buffer
51
ring_buffer_t
rb;
52
char
buf[RB_SIZE];
53
54
// line reading functions
55
int
pushed_back;
// for pushded back char
56
57
}
urg_tcpclient_t
;
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 */
Generated on Thu May 2 2013 10:55:17 by
1.8.3.1