4 * Description: See "socket.c"
6 * Comments: See "notice.txt" for copyright and license information.
18 #include <sys/types.h>
19 #include <sys/socket.h>
22 #include <netinet/in.h>
23 #define closesocket(xxx) close(xxx)
27 #define SOCKETFD SOCKET
32 #define SOCKET_ALREADY_CONNECTED 1
33 #define SOCKET_HOST_NOT_FOUND 2
34 #define SOCKET_COULD_NOT_CREATE_SOCKET 3
35 #define SOCKET_COULD_NOT_CONNECT 4
36 #define SOCKET_READ_ERROR 5
37 #define SOCKET_WRITE_ERROR 6
38 #define SOCKET_NULLPOINTER_PARAMETER 7
39 #define SOCKET_PUT_INT_WRONG_LENGTH 8
40 #define SOCKET_GET_INT_WRONG_LENGTH 9
41 #define SOCKET_CLOSED 10
47 int buffer_filled_out;
49 unsigned char *buffer_in;
50 unsigned char *buffer_out;
57 char reverse; /* used to handle Postgres 6.2 protocol (reverse byte order) */
61 #define SOCK_get_char(self) (SOCK_get_next_byte(self))
62 #define SOCK_put_char(self, c) (SOCK_put_next_byte(self, c))
66 #define SOCK_get_errcode(self) (self->errornumber)
67 #define SOCK_get_errmsg(self) (self->errormsg)
70 /* Socket prototypes */
71 SocketClass *SOCK_Constructor();
72 void SOCK_Destructor(SocketClass *self);
73 char SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname);
74 void SOCK_get_n_char(SocketClass *self, char *buffer, int len);
75 void SOCK_put_n_char(SocketClass *self, char *buffer, int len);
76 void SOCK_get_string(SocketClass *self, char *buffer, int bufsize);
77 void SOCK_put_string(SocketClass *self, char *string);
78 int SOCK_get_int(SocketClass *self, short len);
79 void SOCK_put_int(SocketClass *self, int value, short len);
80 void SOCK_flush_output(SocketClass *self);
81 unsigned char SOCK_get_next_byte(SocketClass *self);
82 void SOCK_put_next_byte(SocketClass *self, unsigned char next_byte);
83 void SOCK_clear_error(SocketClass *self);