24 struct sockaddr_storage from;
25 socklen_t sl =
sizeof (from);
28 if ((recvfrom (vis->
socket, packet, packet_d.
size, 0, (
struct sockaddr *)&from, &sl)) > 0) {
68 c->transport.udp.grace = 2000;
72 gettimeofday (&time, NULL);
74 struct timeval cts, sts;
78 cts.tv_sec = ntohl (cts.tv_sec);
79 cts.tv_usec = ntohl (cts.tv_usec);
81 sts.tv_sec = time.tv_sec - cts.tv_sec;
82 sts.tv_usec = time.tv_usec - cts.tv_usec;
83 if (sts.tv_usec < 0) {
85 sts.tv_usec += 1000000;
89 (int32_t)htonl (sts.tv_sec), int32_t);
91 (int32_t)htonl (sts.tv_usec), int32_t);
93 sendto (vis->
socket, packet, packet_d.
size, 0, (
struct sockaddr *)&from, sl);
115 struct addrinfo hints;
116 struct addrinfo *result, *rp;
119 memset (&hints, 0,
sizeof (hints));
120 hints.ai_family = AF_UNSPEC;
121 hints.ai_socktype = SOCK_DGRAM;
122 hints.ai_flags = AI_PASSIVE;
123 hints.ai_protocol = 0;
127 xmms_log_error (
"Could not setup socket! getaddrinfo: %s", gai_strerror (s));
132 for (rp = result; rp != NULL; rp = rp->ai_next) {
133 vis->
socket = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
137 if (bind (vis->
socket, rp->ai_addr, rp->ai_addrlen) != -1) {
146 freeaddrinfo (result);
149 freeaddrinfo (result);
157 g_io_channel_set_encoding (vis->
socketio, NULL, NULL);
158 g_io_channel_set_buffered (vis->
socketio, FALSE);
159 g_io_add_watch (vis->
socketio, G_IO_IN, (GIOFunc) udpwatcher, vis);
169 xmms_log_info (
"Visualization client %d initialised using UDP",
id);
176 socklen_t sl =
sizeof (t->
addr);
178 sendto (socket, &packet, 1, 0, (
struct sockaddr *)&t->
addr, sl);
205 (int32_t)htonl (time->tv_sec), int32_t);
207 (int32_t)htonl (time->tv_usec), int32_t);
214 offset = ((
char*)&__unaligned_dest->
data - (
char*)__unaligned_dest);