XMMS2
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
lib
xmmssocket
socket_unix.c
Go to the documentation of this file.
1
#include <errno.h>
2
#include "
xmmsc/xmmsc_sockets.h
"
3
4
5
int
xmms_sockets_initialize
() {
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
*/
15
int
xmms_socket_set_nonblock
(
xmms_socket_t
socket) {
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
36
int
xmms_socket_valid
(
xmms_socket_t
socket) {
37
if
(socket < 0) {
38
return
0;
39
}
40
return
1;
41
}
42
43
void
xmms_socket_invalidate
(
xmms_socket_t
*socket) {
44
*socket = -1;
45
}
46
47
void
xmms_socket_close
(
xmms_socket_t
socket) {
48
close (socket);
49
}
50
51
int
xmms_socket_errno
() {
52
return
errno;
53
}
Generated on Wed Apr 10 2013 22:08:53 for XMMS2 by
1.8.3