stream_ctl.c
746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#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);
}
}