Writing a Generic Server

Tutorial: Writing a server — How to write a server

Writing a Server

This section of the tutorial describes how to write a server.

Most servers bind to a #GskSocketAddress using a #GskStreamListenerSocket. They call gsk_stream_listener_handle_accept() to receive notification when new clients have connected.

The easiest way to handle incoming client connections is to make a #GskStream that can handle the protocol. If you do not have an appropriate protocol stream, and don't wish to make one, use a #GskBufferStream to get simple I/O buffering, or one can directly call gsk_stream_trap_readable() and gsk_stream_trap_writable() to get notification when the stream can be written or read.

If the server/client communication is unidirectional, you should probably call gsk_stream_read_shutdown() or gsk_stream_write_shutdown() to terminate whichever direction you don't plan on using.

Example

TODO: write this!