diff --git a/ffserver.c b/ffserver.c
index aa8e72c8964148341985ef8e2ebdb9f52939d7cf..33508ec5eb9e5711513aad94626be72c8e71db7e 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -17,10 +17,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #define HAVE_AV_CONFIG_H
+#include <netinet/in.h>
 #include "avformat.h"
 
 #include <stdarg.h>
-#include <netinet/in.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -31,7 +31,11 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
-#include <arpa/inet.h>
+#ifndef __BEOS__
+# include <arpa/inet.h>
+#else
+# include "libav/barpainet.h"
+#endif
 #include <netdb.h>
 #include <ctype.h>
 #include <signal.h>
diff --git a/libav/http.c b/libav/http.c
index 7271a6da818a960b9bccb4716d76174e505a5476..64025f2258e82547602b4a35a9ce014156c70b1a 100644
--- a/libav/http.c
+++ b/libav/http.c
@@ -16,11 +16,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <sys/socket.h>
 #include "avformat.h"
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>
diff --git a/libav/rtp.c b/libav/rtp.c
index 714787c88b119c118a2f8bbfed3c8d2f38b054c8..b42065fbea666b92dcdcc804110cde6db68df6b6 100644
--- a/libav/rtp.c
+++ b/libav/rtp.c
@@ -16,11 +16,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <sys/socket.h>
 #include "avformat.h"
 
 #include <unistd.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>
diff --git a/libav/rtpproto.c b/libav/rtpproto.c
index 41823fc82937b6ae81a9c7c31dcdd57c602e2099..25b10b8bf2810b9f7df74cea6fb43bd524eef101 100644
--- a/libav/rtpproto.c
+++ b/libav/rtpproto.c
@@ -16,12 +16,12 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <sys/socket.h>
 #include "avformat.h"
 
 #include <unistd.h>
 #include <stdarg.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>
diff --git a/libav/rtsp.c b/libav/rtsp.c
index 81b59f89161aacce2ec6b9b0363f5d5c0b34367d..667a3c095a14d168d72e2c5714f6e47631115dd4 100644
--- a/libav/rtsp.c
+++ b/libav/rtsp.c
@@ -16,10 +16,10 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <netinet/in.h>
 #include "avformat.h"
 
 #include <sys/time.h>
-#include <netinet/in.h>
 #include <sys/socket.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>
diff --git a/libav/tcp.c b/libav/tcp.c
index 61d8665525dda72d35f8ebb2e2de652d9df3d40c..6f4c037dcb9e7b403b5b2c8edd1345d0710a46f6 100644
--- a/libav/tcp.c
+++ b/libav/tcp.c
@@ -16,11 +16,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <sys/socket.h>
 #include "avformat.h"
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>
diff --git a/libav/udp.c b/libav/udp.c
index 8df93a8a8a9ec23967d7061046f434bc3456105a..6e91a22350ae50809db8ec042bc73c3d62261d8e 100644
--- a/libav/udp.c
+++ b/libav/udp.c
@@ -16,10 +16,10 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <sys/socket.h>
 #include "avformat.h"
 #include <unistd.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #ifndef __BEOS__
 # include <arpa/inet.h>