XMMS2
socket_win32.c
Go to the documentation of this file.
1 #include "xmmsc/xmmsc_sockets.h"
2 
4  WSADATA wsaData;
5  int res = WSAStartup (MAKEWORD (2,2), &wsaData);
6  if (res != NO_ERROR) {
7  return 0;
8  }
9  return 1;
10 }
11 
12 /**
13  * Tries to set socket to non-blocking mode.
14  * @param socket Socket to make non-blocking.
15  * On success, returns 1.
16  * On failure, closes socket and returns 0.
17  */
19  unsigned long yes = 1;
20  int err = ioctlsocket (socket, FIONBIO, &yes);
21  if (err == SOCKET_ERROR) {
22  closesocket (socket);
23  return 0;
24  }
25  return 1;
26 
27 }
29  if (socket == INVALID_SOCKET) {
30  return 0;
31  }
32  return 1;
33 }
34 
36  *socket = INVALID_SOCKET;
37 }
38 
40  closesocket (socket);
41 }
42 
44  return WSAGetLastError ();
45 }
int xmms_socket_set_nonblock(xmms_socket_t socket)
Tries to set socket to non-blocking mode.
Definition: socket_win32.c:18
int xmms_socket_valid(xmms_socket_t socket)
Definition: socket_win32.c:28
int xmms_socket_errno()
Definition: socket_win32.c:43
int xmms_socket_t
Definition: xmmsc_sockets.h:37
int xmms_sockets_initialize()
Definition: socket_win32.c:3
void xmms_socket_close(xmms_socket_t socket)
Definition: socket_win32.c:39
#define SOCKET_ERROR
Definition: xmmsc_sockets.h:17
void xmms_socket_invalidate(xmms_socket_t *socket)
Definition: socket_win32.c:35