![]() |
![]() |
![]() |
MateVFS - Filesystem Abstraction library | ![]() |
---|---|---|---|---|
Top | Description |
Unified bufferd network I/OUnified bufferd network I/O — Posix style buffered network input/output. |
typedef MateVFSSocketBuffer; MateVFSSocketBuffer * mate_vfs_socket_buffer_new (MateVFSSocket *socket
); MateVFSResult mate_vfs_socket_buffer_destroy (MateVFSSocketBuffer *socket_buffer
,gboolean close_socket
,MateVFSCancellation *cancellation
); MateVFSResult mate_vfs_socket_buffer_read (MateVFSSocketBuffer *socket_buffer
,gpointer buffer
,MateVFSFileSize bytes
,MateVFSFileSize *bytes_read
,MateVFSCancellation *cancellation
); MateVFSResult mate_vfs_socket_buffer_peekc (MateVFSSocketBuffer *socket_buffer
,char *character
,MateVFSCancellation *cancellation
); MateVFSResult mate_vfs_socket_buffer_write (MateVFSSocketBuffer *socket_buffer
,gconstpointer buffer
,MateVFSFileSize bytes
,MateVFSFileSize *bytes_written
,MateVFSCancellation *cancellation
); MateVFSResult mate_vfs_socket_buffer_flush (MateVFSSocketBuffer *socket_buffer
,MateVFSCancellation *cancellation
); MateVFSResult mate_vfs_socket_buffer_read_until (MateVFSSocketBuffer *socket_buffer
,gpointer buffer
,MateVFSFileSize bytes
,gconstpointer boundary
,MateVFSFileSize boundary_len
,MateVFSFileSize *bytes_read
,gboolean *got_boundary
,MateVFSCancellation *cancellation
);
The MateVFSSocketBuffer functions are very similar to the MateVFSSocket ones. The only difference is that all input/output is done through an internally managed buffer. This might increase I/O performance as well as give you the possibility to use some convenient functions like mate_vfs_socket_buffer_peekc and mate_vfs_socket_buffer_read_until.
You can manually force all internally buffered data to get written with mate_vfs_socket_buffer_flush.
typedef struct MateVFSSocketBuffer MateVFSSocketBuffer;
A handle to a socket buffer. A socket buffer is a temporary in-memory storage for data that is read from or written to a MateVFSSocket.
MateVFSSocketBuffer * mate_vfs_socket_buffer_new (MateVFSSocket *socket
);
Create a socket buffer around socket
. A buffered
socket allows data to be poked at without reading it
as it will be buffered. A future read will retrieve
the data again.
|
socket to be buffered. |
Returns : |
a newly allocated MateVFSSocketBuffer. |
MateVFSResult mate_vfs_socket_buffer_destroy (MateVFSSocketBuffer *socket_buffer
,gboolean close_socket
,MateVFSCancellation *cancellation
);
Free the socket buffer.
|
buffered socket to destroy. |
|
if TRUE , the socket being buffered will be closed.
|
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
MateVFSResult mate_vfs_socket_buffer_read (MateVFSSocketBuffer *socket_buffer
,gpointer buffer
,MateVFSFileSize bytes
,MateVFSFileSize *bytes_read
,MateVFSCancellation *cancellation
);
Read bytes
bytes of data from the socket
into socket_buffer
.
|
buffered socket to read data from. |
|
allocated buffer of at least bytes bytes to be read into.
|
|
number of bytes to read from socket_buffer into buffer .
|
|
pointer to a MateVFSFileSize, will contain
the number of bytes actually read from the socket_buffer on return.
|
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
MateVFSResult mate_vfs_socket_buffer_peekc (MateVFSSocketBuffer *socket_buffer
,char *character
,MateVFSCancellation *cancellation
);
Peek at the next character in socket_buffer
without actually reading
the character in. The next read will retrieve c
(as well as any following
data if requested).
|
the socket buffer to read from. |
|
pointer to a char, will contain a character on return from a successful "peek". |
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
MateVFSResult mate_vfs_socket_buffer_write (MateVFSSocketBuffer *socket_buffer
,gconstpointer buffer
,MateVFSFileSize bytes
,MateVFSFileSize *bytes_written
,MateVFSCancellation *cancellation
);
Write bytes
bytes of data from buffer
to socket_buffer
.
|
buffered socket to write data to. |
|
data to write to the socket_buffer .
|
|
number of bytes to write from buffer to socket_buffer .
|
|
pointer to a MateVFSFileSize, will contain
the number of bytes actually written to the socket_buffer on return.
|
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
MateVFSResult mate_vfs_socket_buffer_flush (MateVFSSocketBuffer *socket_buffer
,MateVFSCancellation *cancellation
);
Write all outstanding data to socket_buffer
.
|
buffer to flush. |
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
MateVFSResult mate_vfs_socket_buffer_read_until (MateVFSSocketBuffer *socket_buffer
,gpointer buffer
,MateVFSFileSize bytes
,gconstpointer boundary
,MateVFSFileSize boundary_len
,MateVFSFileSize *bytes_read
,gboolean *got_boundary
,MateVFSCancellation *cancellation
);
Read up to bytes
bytes of data from the socket_buffer
into buffer
until boundary is reached. got_boundary
will be set accordingly.
Note that if bytes
is smaller than boundary_len
there is no way
to detected the boundary! So if you want to make sure that every boundary
is found (in a loop maybe) assure that bytes
is at least as big as
boundary_len
.
|
buffered socket to read data from. |
|
allocated buffer of at least bytes bytes to be read into.
|
|
maximum number of bytes to read from socket_buffer into buffer .
|
|
the boundary until which is read. |
|
the length of the boundary .
|
|
pointer to a MateVFSFileSize, will contain
the number of bytes actually read from the socket_buffer on return.
|
|
pointer to a gboolean which will be TRUE if the boundary
was found or FALSE otherwise.
|
|
handle allowing cancellation of the operation. |
Returns : |
MateVFSResult indicating the success of the operation. |
Since 2.8