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
|
Read exactly len bytes from the channel the buffer to the channel.
This is basically a wrapper around
|
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.
|
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.
typedef enum { GNET_IOCHANNEL_WRITE_ASYNC_STATUS_OK, GNET_IOCHANNEL_WRITE_ASYNC_STATUS_TIMEOUT, GNET_IOCHANNEL_WRITE_ASYNC_STATUS_ERROR } GNetIOChannelWriteAsyncStatus; |
Status for an asynchronous write via gnet_io_channel_write_async(), passed by GNetIOChannelWriteAsyncFunc.
ID of an asynchronous write started with gnet_io_channel_write_async(). The connection can be canceled by calling gnet_io_channel_write_async_cancel() with the ID.
GNetIOChannelWriteAsyncID gnet_io_channel_write_async ( |
Write buffer to iochannel asynchronously. When the operation is complete, func is called. The callback may also be called if there is an error or timeout. The timeout is in milliseconds. Use a timeout of 0 if no timeout is needed.
void gnet_io_channel_write_async_cancel (GNetIOChannelWriteAsyncID id, |
Cancel an asynchronous write that was started with gnet_io_channel_write_async(). Set delete_buffer to TRUE if the buffer should be deleted. TODO: The delete_buffer functionality will probably be removed in the next version (it will remain in GConn).
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); |
|
|