23 struct sockaddr_storage from;
24 socklen_t sl =
sizeof (from);
27 if ((recvfrom (vis->
socket, packet, packet_d.
size, 0, (
struct sockaddr *)&from, &sl)) > 0) {
67 c->transport.udp.grace = 2000;
71 gettimeofday (&time, NULL);
73 struct timeval cts, sts;
77 cts.tv_sec = ntohl (cts.tv_sec);
78 cts.tv_usec = ntohl (cts.tv_usec);
80 sts.tv_sec = time.tv_sec - cts.tv_sec;
81 sts.tv_usec = time.tv_usec - cts.tv_usec;
82 if (sts.tv_usec < 0) {
84 sts.tv_usec += 1000000;
88 (int32_t)htonl (sts.tv_sec), int32_t);
90 (int32_t)htonl (sts.tv_usec), int32_t);
92 sendto (vis->
socket, packet, packet_d.
size, 0, (
struct sockaddr *)&from, sl);
114 struct addrinfo hints;
115 struct addrinfo *result, *rp;
118 memset (&hints, 0,
sizeof (hints));
119 hints.ai_family = AF_UNSPEC;
120 hints.ai_socktype = SOCK_DGRAM;
121 hints.ai_flags = AI_PASSIVE;
122 hints.ai_protocol = 0;
126 xmms_log_error (
"Could not setup socket! getaddrinfo: %s", gai_strerror (s));
131 for (rp = result; rp != NULL; rp = rp->ai_next) {
132 vis->
socket = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
136 if (bind (vis->
socket, rp->ai_addr, rp->ai_addrlen) != -1) {
145 freeaddrinfo (result);
148 freeaddrinfo (result);
156 g_io_channel_set_encoding (vis->
socketio, NULL, NULL);
157 g_io_channel_set_buffered (vis->
socketio, FALSE);
158 g_io_add_watch (vis->
socketio, G_IO_IN, (GIOFunc) udpwatcher, vis);
168 xmms_log_info (
"Visualization client %d initialised using UDP",
id);
175 socklen_t sl =
sizeof (t->
addr);
177 sendto (socket, &packet, 1, 0, (
struct sockaddr *)&t->
addr, sl);
204 (int32_t)htonl (time->tv_sec), int32_t);
206 (int32_t)htonl (time->tv_usec), int32_t);
213 offset = ((
char*)&__unaligned_dest->
data - (
char*)__unaligned_dest);