## gnome-vfs-socket-buffer

gnome-vfs-socket-buffer —

## Synopsis

    GnomeVFSSocketBuffer* gnome_vfs_socket_buffer_new
                                                (GnomeVFSSocket *socket);
    GnomeVFSResult gnome_vfs_socket_buffer_destroy
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 gboolean close_socket);
    GnomeVFSResult gnome_vfs_socket_buffer_read (GnomeVFSSocketBuffer *socket_buffer,
                                                 gpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_read);
    GnomeVFSResult gnome_vfs_socket_buffer_peekc
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 char *character);
    GnomeVFSResult gnome_vfs_socket_buffer_write
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 gconstpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_written);
    GnomeVFSResult gnome_vfs_socket_buffer_flush
                                                (GnomeVFSSocketBuffer *socket_buffer);

## Description

## Details

### gnome_vfs_socket_buffer_new ()

    GnomeVFSSocketBuffer* gnome_vfs_socket_buffer_new
                                                (GnomeVFSSocket *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` : | socket to be buffered
Returns : | a newly allocated GnomeVFSSocketBuffer

### gnome_vfs_socket_buffer_destroy ()

    GnomeVFSResult gnome_vfs_socket_buffer_destroy
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 gboolean close_socket);

Free the socket buffer.

`socket_buffer` : | buffered socket to destray
`close_socket` : | if `TRUE` the socket being buffered will be closed too
Returns : | GnomeVFSResult indicating the success of the operation

### gnome_vfs_socket_buffer_read ()

    GnomeVFSResult gnome_vfs_socket_buffer_read (GnomeVFSSocketBuffer *socket_buffer,
                                                 gpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_read);

Read `bytes` bytes of data from the `socket` into `socket_buffer`.

`socket_buffer` : | buffered socket to read data from
`buffer` : | allocated buffer of at least `bytes` bytes to be read into
`bytes` : | number of bytes to read from `socket` into `socket_buffer`
`bytes_read` : | pointer to a GnomeVFSFileSize, will contain the number of bytes actually read from the socket on return.
Returns : | GnomeVFSResult indicating the success of the operation

### gnome_vfs_socket_buffer_peekc ()

    GnomeVFSResult gnome_vfs_socket_buffer_peekc
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 char *character);

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).

`socket_buffer` : | the socket buffer to read from
`character` : | pointer to a char, will contain a character on return from a successful "peek"
Returns : | GnomeVFSResult indicating the success of the operation

### gnome_vfs_socket_buffer_write ()

    GnomeVFSResult gnome_vfs_socket_buffer_write
                                                (GnomeVFSSocketBuffer *socket_buffer,
                                                 gconstpointer buffer,
                                                 GnomeVFSFileSize bytes,
                                                 GnomeVFSFileSize *bytes_written);

Write `bytes` bytes of data from `buffer` to `socket_buffer`.

`socket_buffer` : | buffered socket to write data to
`buffer` : | data to write to the socket
`bytes` : | number of bytes from `buffer` to write to `socket_buffer`
`bytes_written` : | pointer to a GnomeVFSFileSize, will contain the number of bytes actually written to the socket on return.
Returns : | GnomeVFSResult indicating the success of the operation

### gnome_vfs_socket_buffer_flush ()

    GnomeVFSResult gnome_vfs_socket_buffer_flush
                                                (GnomeVFSSocketBuffer *socket_buffer);

Write all outstanding data to `socket_buffer`.

`socket_buffer` : | buffer to flush
Returns : | GnomeVFSResult indicating the success of the operation