#endif
static GIOStatus
-g_io_win32_set_flags (GIOChannel *channel,
- GIOFlags flags,
- GError **err)
+g_io_win32_unimpl_set_flags (GIOChannel *channel,
+ GIOFlags flags,
+ GError **err)
{
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
if (win32_channel->debug)
{
- g_print ("g_io_win32_set_flags: ");
+ g_print ("g_io_win32_unimpl_set_flags: ");
g_win32_print_gioflags (flags);
g_print ("\n");
}
return 0;
}
+static GIOStatus
+g_io_win32_sock_set_flags (GIOChannel *channel,
+ GIOFlags flags,
+ GError **err)
+{
+ GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
+ u_long arg;
+
+ if (win32_channel->debug)
+ {
+ g_print ("g_io_win32_sock_set_flags: ");
+ g_win32_print_gioflags (flags);
+ g_print ("\n");
+ }
+
+ if (flags & G_IO_FLAG_NONBLOCK)
+ {
+ arg = 1;
+ if (ioctlsocket (win32_channel->fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ g_set_error (err, G_IO_CHANNEL_ERROR,
+ G_IO_CHANNEL_ERROR_FAILED,
+ winsock_error_message (WSAGetLastError ()));
+ return G_IO_STATUS_ERROR;
+ }
+ }
+ else
+ {
+ arg = 0;
+ if (ioctlsocket (win32_channel->fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ g_set_error (err, G_IO_CHANNEL_ERROR,
+ G_IO_CHANNEL_ERROR_FAILED,
+ winsock_error_message (WSAGetLastError ()));
+ return G_IO_STATUS_ERROR;
+ }
+ }
+
+ return G_IO_STATUS_NORMAL;
+}
+
static GIOFlags
g_io_win32_sock_get_flags (GIOChannel *channel)
{
- /* XXX Could do something here. */
+ /* Could we do something here? */
return 0;
}
g_io_win32_msg_close,
g_io_win32_msg_create_watch,
g_io_win32_free,
- g_io_win32_set_flags,
+ g_io_win32_unimpl_set_flags,
g_io_win32_msg_get_flags,
};
g_io_win32_fd_close,
g_io_win32_fd_create_watch,
g_io_win32_free,
- g_io_win32_set_flags,
+ g_io_win32_unimpl_set_flags,
g_io_win32_fd_get_flags,
};
g_io_win32_sock_close,
g_io_win32_sock_create_watch,
g_io_win32_free,
- g_io_win32_set_flags,
+ g_io_win32_sock_set_flags,
g_io_win32_sock_get_flags,
};