]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_socket.h
Initial revision
[OpenSRF.git] / include / opensrf / transport_socket.h
1 #include "generic_utils.h"
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <sys/types.h>
6 #include <errno.h>
7
8 //---------------------------------------------------------------
9 // WIN32
10 //---------------------------------------------------------------
11 #ifdef WIN32
12 #include <Windows.h>
13 #include <Winsock.h>
14 #else
15
16 //---------------------------------------------------------------
17 // Unix headers
18 //---------------------------------------------------------------
19 #include <unistd.h>
20 #include <sys/time.h>
21 #include <sys/stat.h>
22 #include <fcntl.h>
23 #include <sys/socket.h>
24 #include <arpa/inet.h>
25 #include <netdb.h>
26 #include <netinet/in.h>
27 #endif
28
29 #ifdef DMALLOC
30 #include "dmalloc.h"
31 #endif
32
33 #ifndef TRANSPORT_SOCKET_H
34 #define TRANSPORT_SOCKET_H
35
36 /* how many characters we read from the socket at a time */
37 #ifdef _ROUTER
38 #define BUFSIZE 412
39 #else
40 #define BUFSIZE 4096
41 #endif
42
43 /* we maintain the socket information */
44 struct transport_socket_struct {
45         int sock_fd;
46         int connected;
47         char* server;
48         int port;
49         void * user_data;
50         /* user_data may be anything.  it's whatever you wish
51                 to see showing up in the callback in addition to
52                 the acutal character data*/
53         void (*data_received_callback) (void * user_data, char*);
54 };
55 typedef struct transport_socket_struct transport_socket;
56
57 int tcp_connect( transport_socket* obj );
58 int tcp_send( transport_socket* obj, const char* data );
59 int tcp_disconnect( transport_socket* obj );
60 int tcp_wait( transport_socket* obj, int timeout );
61 int tcp_connected( transport_socket* obj );
62
63 /* utility methods */
64 int set_fl( int fd, int flags );
65 int clr_fl( int fd, int flags );
66
67
68 #endif