GNet Network Library Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
|
|
Write all len bytes in the buffer to the channel. This is
basically a wrapper around
channel : | the channel to write to |
buf : | the buffer to read from |
len : | length of the buffer |
bytes_written : | pointer to integer for the function to store the number of bytes writen. |
Returns : | G_IO_ERROR_NONE if everything is ok; something else otherwise. Also, returns the number of bytes writen by modifying the integer pointed to by bytes_written. |
|
Read exactly len bytes from the channel the buffer to the channel.
This is basically a wrapper around
channel : | the channel to read from |
buf : | the buffer to write to |
len : | the length of the buffer |
bytes_read : | pointer to integer for the function to store the number of of bytes read. |
Returns : | G_IO_ERROR_NONE if everything is ok; something else otherwise. Also, returns the number of bytes read by modifying the integer pointed to by bytes_read. If bytes_read is 0, the end of the file has been reached (eg, the socket has been closed). |
|
Read a line from the channel. The line will be null-terminated and include the newline character. If there is not enough room for the line, the line is truncated to fit in the buffer.
Warnings: (in the gotcha sense, not the bug sense)
1. If the buffer is full and the last character is not a newline, the line was truncated. So, do not assume the buffer ends with a newline.
2. bytes_read is actually the number of bytes put in the buffer. That is, it includes the terminating null character.
3. Null characters can appear in the line before the terminating null (I could send the string "Hello world\0\n"). If this matters in your program, check the string length of the buffer against the bytes read.
I hope this isn't too confusing. Usually the function works as you expect it to if you have a big enough buffer. If you have the Stevens book, you should be familiar with the semantics.
channel : | the channel to read from |
buf : | the buffer to write to |
len : | length of the buffer |
bytes_read : | pointer to integer for the function to store the number of of bytes read. |
Returns : | G_IO_ERROR_NONE if everything is ok; something else otherwise. Also, returns the number of bytes read by modifying the integer pointed to by bytes_read (this number includes the newline). If an error is returned, the contents of buf and bytes_read are undefined. |
|
Read a line from the channel. The line will be null-terminated and include the newline character. Similarly to g_strdup_printf, a buffer large enough to hold the string will be allocated.
Warnings: (in the gotcha sense, not the bug sense)
1. If the last character of the buffer is not a newline, the line was truncated by EOF. So, do not assume the buffer ends with a newline.
2. bytes_read is actually the number of bytes put in the buffer. That is, it includes the terminating null character.
3. Null characters can appear in the line before the terminating null (I could send the string "Hello world\0\n"). If this matters in your program, check the string length of the buffer against the bytes read.
channel : | the channel to read from |
buf_ptr : | pointer to gchar* for the functin to store the new buffer |
bytes_read : | pointer to integer for the function to store the number of of bytes read. |
Returns : | G_IO_ERROR_NONE if everything is ok; something else
otherwise. Also, returns the number of bytes read by modifying the
integer pointed to by bytes_read (this number includes the
newline), and the data through the pointer pointed to by buf_ptr.
This data should be freed with |
typedef enum { GNET_IOCHANNEL_WRITE_ASYNC_STATUS_OK, GNET_IOCHANNEL_WRITE_ASYNC_STATUS_TIMEOUT, GNET_IOCHANNEL_WRITE_ASYNC_STATUS_ERROR } GNetIOChannelWriteAsyncStatus; |
GNetIOChannelWriteAsyncID gnet_io_channel_write_async ( |
void gnet_io_channel_write_async_cancel (GNetIOChannelWriteAsyncID id, |
typedef enum { GNET_IOCHANNEL_READ_ASYNC_STATUS_OK, GNET_IOCHANNEL_READ_ASYNC_STATUS_TIMEOUT, GNET_IOCHANNEL_READ_ASYNC_STATUS_ERROR } GNetIOChannelReadAsyncStatus; |
GNetIOChannelReadAsyncID gnet_io_channel_read_async ( |
void gnet_io_channel_read_async_cancel (GNetIOChannelReadAsyncID id); |
|
|