Código
#include<winsock2.h> #include<stdio.h> int main() { int s; if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return 1; } }
En mi caso al compilar y ejecutar el codigo anterior siempre me devuelve menos -1
Código:
C:\> gcc -o test.exe test.c -lws2_32
C:\> test.exe
Valor -1
socket: No error
El codigo original es mas extenso, pero incluso con ese fragmento basico de codigo me devulve error...
Version de gcc
Código:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
Voy a tratar de actualizar el mingw
Saludos