XMMS2
socket_unix.c
Go to the documentation of this file.
1#include <errno.h>
3
4
6 return 1;
7}
8
9/**
10 * Tries to set socket to non-blocking mode.
11 * @param socket Socket to make non-blocking.
12 * On success, returns 1.
13 * On failure, closes socket and returns 0.
14 */
16
17 int flags;
18 flags = fcntl (socket, F_GETFL, 0);
19
20 if (flags == -1) {
21 close (socket);
22 return 0;
23 }
24
25 flags |= O_NONBLOCK;
26
27 flags = fcntl (socket, F_SETFL, flags);
28 if (flags == -1) {
29 close (socket);
30 return 0;
31 }
32 return 1;
33}
34
35
37 if (socket < 0) {
38 return 0;
39 }
40 return 1;
41}
42
44 *socket = -1;
45}
46
48 close (socket);
49}
50
52 return errno;
53}
int xmms_socket_t
Definition: xmmsc_sockets.h:37
void xmms_socket_close(xmms_socket_t socket)
Definition: socket_unix.c:47
int xmms_socket_errno()
Definition: socket_unix.c:51
void xmms_socket_invalidate(xmms_socket_t *socket)
Definition: socket_unix.c:43
int xmms_sockets_initialize()
Definition: socket_unix.c:5
int xmms_socket_valid(xmms_socket_t socket)
Definition: socket_unix.c:36
int xmms_socket_set_nonblock(xmms_socket_t socket)
Tries to set socket to non-blocking mode.
Definition: socket_unix.c:15