/*****************************************************************************
* network.c: functions to read from the network
- * (c)1999 VideoLAN
- *****************************************************************************
* Manages a socket.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h> /* servent, getservbyname(), hostent, gethostbyname() */
-#include <sys/socket.h> /* socket(), setsockopt(), bind(), connect() */
+#include <sys/types.h> /* on BSD, uio.h needs types.h */
+#include <sys/uio.h> /* "input.h" */
+#include <string.h> /* strerror() */
#include <unistd.h> /* close() */
+#include <errno.h> /* errno */
+#include <sys/time.h> /* "input_network.h" */
+
+#if defined(SYS_BSD) || defined(SYS_BEOS)
+#include <sys/socket.h> /* struct sockaddr */
+#endif
+
+#include <netdb.h> /* servent, getservbyname(), hostent, gethostbyname() */
#include <netinet/in.h> /* sockaddr_in, htons(), htonl() */
-#include <errno.h>
-#include <sys/time.h>
-#include <unistd.h>
+#include "threads.h"
#include "common.h"
#include "config.h"
#include "mtime.h"
-#include "vlc_thread.h"
#include "netutils.h"
#include "input.h"
&i_socket_option,
sizeof( i_socket_option ) ) == (-1) )
{
- intf_ErrMsg("error: can't configure socket (%s)\n", strerror(errno));
+ intf_ErrMsg("error: can't configure socket (SO_REUSEADDR: %s)\n", strerror(errno));
close( p_input->i_handle );
return( 1 );
}
+#ifndef SYS_BEOS
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s) to avoid
* packet loss caused by scheduling problems */
i_socket_option = 524288;
&i_socket_option,
sizeof( i_socket_option ) ) == (-1) )
{
- intf_ErrMsg("error: can't configure socket (%s)\n", strerror(errno));
+ intf_ErrMsg("error: can't configure socket (SO_RCVBUF: %s)\n", strerror(errno));
close( p_input->i_handle );
return( 1 );
}
+#endif /* SYS_BEOS */
/*
* Bind the socket