/*************************************************************************************************************
* This file contains creating of server channel
* 2012/8 by Dlxko
* Version 3.0
**************************************************************************************************************/
#include "ServerChannel.h"

// Local static variables
static GIOChannel *gich;
static guint event_id;

// Function to create channel
bool create_server_channel()
{
	// Get channel
	gich = g_io_channel_win32_new_socket (server_socket);
	if (!gich)
		return false;

	// Set encoding
	if(g_io_channel_set_encoding(gich, NULL, NULL) != G_IO_STATUS_NORMAL)
	{
		function_show_error("GIOChannel initialization - can't change coding.\n");
		return false;
	}

	// Close on unref
	g_io_channel_set_close_on_unref(gich, TRUE);

	// Add watchdog
	event_id = g_io_add_watch_full( gich, 0, G_IO_IN, (GIOFunc)signal_accept_client, NULL, NULL );
	if (!event_id)
		return false;

	return true;
}