+#ifdef UNDER_CE
+ return -1;
+#else
+ access_t *p_access = (access_t*)p_input->p_access_data;
+ struct timeval timeout;
+ fd_set fds;
+ int i_ret;
+
+ /* FIXME when using udp */
+ ssize_t i_tcp, i_udp;
+ ssize_t i_tcp_read, i_udp_read;
+ int i_handle_max;
+
+ /* Initialize file descriptor set */
+ FD_ZERO( &fds );
+
+ i_tcp = MMS_BUFFER_SIZE/2 - p_access->i_buffer_tcp;
+
+ if( p_access->i_proto == MMS_PROTO_UDP )
+ {
+ i_udp = MMS_BUFFER_SIZE/2 - p_access->i_buffer_udp;
+ }
+ else
+ {
+ i_udp = 0; /* there isn't udp socket */
+ }
+
+ i_handle_max = 0;
+ if( i_tcp > 0 )
+ {
+ FD_SET( p_access->socket_tcp.i_handle, &fds );
+ i_handle_max = __MAX( i_handle_max, p_access->socket_tcp.i_handle );
+ }
+ if( i_udp > 0 )
+ {
+ FD_SET( p_access->socket_udp.i_handle, &fds );
+ i_handle_max = __MAX( i_handle_max, p_access->socket_udp.i_handle );
+ }
+
+ if( i_handle_max == 0 )
+ {
+ msg_Warn( p_input, "nothing to read %d:%d", i_tcp, i_udp );
+ return( 0 );
+ }
+ else
+ {
+// msg_Warn( p_input, "ask for tcp:%d udp:%d", i_tcp, i_udp );
+ }
+
+ /* We'll wait 0.5 second if nothing happens */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500000;
+
+ /* Find if some data is available */
+ while( (i_ret = select( i_handle_max + 1, &fds,
+ NULL, NULL, &timeout )) == 0
+ || (i_ret < 0 && errno == EINTR) )
+ {
+ FD_ZERO( &fds );
+ if( i_tcp > 0 ) FD_SET( p_access->socket_tcp.i_handle, &fds );
+ if( i_udp > 0 ) FD_SET( p_access->socket_udp.i_handle, &fds );
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500000;
+
+ if( p_input->b_die || p_input->b_error )
+ {
+ return 0;
+ }
+ }
+
+ if( i_ret < 0 )
+ {
+ msg_Err( p_input, "network select error (%s)", strerror(errno) );
+ return -1;
+ }
+
+ if( i_tcp > 0 && FD_ISSET( p_access->socket_tcp.i_handle, &fds ) )
+ {
+ i_tcp_read =
+ recv( p_access->socket_tcp.i_handle,
+ p_access->buffer_tcp + p_access->i_buffer_tcp,
+ i_tcp + MMS_BUFFER_SIZE/2, 0 );
+ }
+ else
+ {
+ i_tcp_read = 0;
+ }
+
+ if( i_udp > 0 && FD_ISSET( p_access->socket_udp.i_handle, &fds ) )
+ {
+ i_udp_read = recv( p_access->socket_udp.i_handle,
+ p_access->buffer_udp + p_access->i_buffer_udp,
+ i_udp + MMS_BUFFER_SIZE/2, 0 );
+ }
+ else
+ {
+ i_udp_read = 0;
+ }
+
+#if MMS_DEBUG
+ if( p_access->i_proto == MMS_PROTO_UDP )
+ {
+ msg_Dbg( p_input,
+ "filling buffer TCP:%d+%d UDP:%d+%d",
+ p_access->i_buffer_tcp,
+ i_tcp_read,
+ p_access->i_buffer_udp,
+ i_udp_read );
+ }
+ else
+ {
+ msg_Dbg( p_input,
+ "filling buffer TCP:%d+%d",
+ p_access->i_buffer_tcp,
+ i_tcp_read );
+ }
+#endif
+ if( i_tcp_read > 0 )
+ {
+ p_access->i_buffer_tcp += i_tcp_read;
+ }
+ if( i_udp_read > 0 )
+ {
+ p_access->i_buffer_udp += i_udp_read;
+ }
+
+ return( i_tcp_read + i_udp_read);
+#endif
+}
+
+static int mms_ParseCommand( input_thread_t *p_input,
+ uint8_t *p_data,
+ int i_data,
+ int *pi_used )
+{
+ #define GET32( i_pos ) \