stream_ctl.c 746 Bytes
#include <windows.h>
#include <winsock2.h>

#include <scot/stream.h>
#include <scot/exception.h>

#include <scot_common.h>

int
scot_stream_get_blocking (struct scot_stream * s)
{
	return s->s_blk;
}

void
scot_stream_set_block (struct scot_stream * s)
{
	u_long blk = 0;
	/*
	 * actually only socket can be set to non-blocking io
	 * under windows...
	 */
	if (s->s_type == SCOT_STREAM_TYPE_SOCKET)
	{
		s->s_blk = 1;
		ioctlsocket (s->handle.sock, FIONBIO, &blk);
	}
}

void
scot_stream_set_nonblock (struct scot_stream * s)
{
	u_long blk = 1;
	/*
	 * actually only socket can be set to non-blocking io
	 * under windows...
	 */
	if (s->s_type == SCOT_STREAM_TYPE_SOCKET)
	{
		s->s_blk = 0;
		ioctlsocket (s->handle.sock, FIONBIO, &blk);
	}
}