2000-07-16 15:00:41 -04:00
|
|
|
#ifndef __NET_SENDBUFFER_H
|
|
|
|
#define __NET_SENDBUFFER_H
|
|
|
|
|
|
|
|
#define DEFAULT_BUFFER_SIZE 8192
|
2008-05-22 17:42:29 -04:00
|
|
|
#define MAX_BUFFER_SIZE 1048576
|
2000-07-16 15:00:41 -04:00
|
|
|
|
2005-08-24 15:42:17 -04:00
|
|
|
struct _NET_SENDBUF_REC {
|
|
|
|
GIOChannel *handle;
|
2008-05-22 18:38:29 -04:00
|
|
|
LINEBUF_REC *readbuffer; /* receive buffer */
|
2005-08-24 15:42:17 -04:00
|
|
|
|
|
|
|
int send_tag;
|
|
|
|
int bufsize;
|
|
|
|
int bufpos;
|
|
|
|
char *buffer; /* Buffer is NULL until it's actually needed. */
|
2008-05-22 17:42:29 -04:00
|
|
|
int def_bufsize;
|
|
|
|
unsigned int dead:1;
|
2005-08-24 15:42:17 -04:00
|
|
|
};
|
|
|
|
|
2000-07-16 15:00:41 -04:00
|
|
|
/* Create new buffer - if `bufsize' is zero or less, DEFAULT_BUFFER_SIZE
|
|
|
|
is used */
|
2000-12-04 17:57:18 -05:00
|
|
|
NET_SENDBUF_REC *net_sendbuffer_create(GIOChannel *handle, int bufsize);
|
2000-07-16 15:00:41 -04:00
|
|
|
/* Destroy the buffer. `close' specifies if socket handle should be closed. */
|
|
|
|
void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close);
|
|
|
|
|
|
|
|
/* Send data, if all of it couldn't be sent immediately, it will be resent
|
|
|
|
automatically after a while. Returns -1 if some unrecoverable error
|
2014-11-08 17:26:53 -05:00
|
|
|
occurred. */
|
2000-07-23 09:41:34 -04:00
|
|
|
int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size);
|
2000-07-16 15:00:41 -04:00
|
|
|
|
2008-05-22 18:38:29 -04:00
|
|
|
int net_sendbuffer_receive_line(NET_SENDBUF_REC *rec, char **str, int read_socket);
|
|
|
|
|
2001-11-19 19:54:51 -05:00
|
|
|
/* Flush the buffer, blocks until finished. */
|
|
|
|
void net_sendbuffer_flush(NET_SENDBUF_REC *rec);
|
|
|
|
|
2000-07-16 15:00:41 -04:00
|
|
|
/* Returns the socket handle */
|
2000-12-04 17:57:18 -05:00
|
|
|
GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec);
|
2000-07-16 15:00:41 -04:00
|
|
|
|
|
|
|
#endif
|