diff --git a/configure b/configure
index c95d900553ee637298948fe590b4f8a6df5e4ef6..0cc53f893ac280355a15ddbac1527e2565401c88 100755
--- a/configure
+++ b/configure
@@ -551,6 +551,23 @@ int main(void){
 EOF
 }
 
+check_type(){
+    log check_type "$@"
+    headers=$1
+    type=$2
+    shift 2
+    disable $type
+    incs=""
+    for hdr in $headers; do
+        incs="$incs
+#include <$hdr>"
+    done
+    check_cc "$@" <<EOF && enable $type
+$incs
+$type v;
+EOF
+}
+
 require(){
     name="$1"
     header="$2"
@@ -720,6 +737,7 @@ HAVE_LIST="
     roundf
     sdl
     sdl_video_size
+    socklen_t
     soundcard_h
     sys_poll_h
     sys_select_h
@@ -1684,6 +1702,8 @@ fi
 
 texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
 
+check_type sys/socket.h socklen_t
+
 ##########################################
 # Network check
 
@@ -1693,6 +1713,7 @@ if enabled network; then
         check_func closesocket
     elif check_header winsock2.h ; then
         network_extralibs="-lws2_32"
+        check_type ws2tcpip.h socklen_t
         check_func2 winsock2.h closesocket
     fi
 fi
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 16c198eb4f2b505b85c90f3f7741357af2d88e3e..1c57895ab6f1cc4384099c2f5fd8dd45f2d19701 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -27,7 +27,7 @@
  * miscellaneous OS support macros and functions.
  */
 
-#if defined(__BEOS__) || defined(__INNOTEK_LIBC__) || defined(__DJGPP__)
+#ifndef HAVE_SOCKLEN_T
 typedef int socklen_t;
 #endif