buen espeor que me puedan ayudar bueno es que anterior mente ya habia compilado sockets en c en codeblock y en devc++ pero ahora ya no me quiere compilar en codeblocks me sale esto:
Código
C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h||In function 'Ptr32ToPtr':| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h|299|warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h||In function 'Handle32ToHandle':| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h|308|warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h||In function 'PtrToPtr32':| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\basetsd.h|317|warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]| C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h|307|warning: "_cdecl" redefined [enabled by default]| C:\progc\pruebas\sock.c|1|note: this is the location of the previous definition| C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h|308|warning: "__cdecl" redefined [enabled by default]| C:\progc\pruebas\sock.c|1|note: this is the location of the previous definition| C:\Program Files (x86)\Windows Kits\8.0\Include\um\winuser.h|1086|warning: declaration does not declare anything [enabled by default]| C:\Program Files (x86)\Windows Kits\8.0\Include\um\winuser.h|12838|warning: declaration does not declare anything [enabled by default]| C:\Program Files (x86)\Windows Kits\8.0\Include\um\winuser.h|12843|warning: declaration does not declare anything [enabled by default]| C:\Program Files (x86)\Windows Kits\8.0\Include\um\objidl.h|11066|warning: declaration does not declare anything [enabled by default]| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\wtypes.h|752|error: pasting "/" and "/" does not give a valid preprocessing token| C:\Program Files (x86)\Windows Kits\8.0\Include\um\oaidl.h|473|note: in expansion of macro '_VARIANT_BOOL'| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\wtypes.h|752|error: expected specifier-qualifier-list before '/' token| C:\Program Files (x86)\Windows Kits\8.0\Include\um\oaidl.h|473|note: in expansion of macro '_VARIANT_BOOL'| C:\Program Files (x86)\Windows Kits\8.0\Include\shared\wtypes.h|752|error: pasting "/" and "/" does not give a valid preprocessing token| C:\Program Files (x86)\Windows Kits\8.0\Include\um\oaidl.h|488|note: in expansion of macro '_VARIANT_BOOL'| C:\Program Files (x86)\Windows Kits\8.0\Include\um\propidl.h|647|error: array type has incomplete element type| C:\Program Files (x86)\Windows Kits\8.0\Include\um\propidl.h|653|error: array type has incomplete element type| ||=== Build failed: 5 error(s), 9 warning(s) (0 minute(s), 1 second(s)) ===|
en dev c++ me sale lo siguiente:
Código
239 0 C:\mingw completo\mingw\include\windef.h In file included from C:\mingw completo\mingw\include/windef.h 60 C:\mingw completo\mingw\include\windows.h from C:\mingw completo\mingw\include/windows.h 22 C:\mingw completo\mingw-mingw-w32api\include\winsock2.h from C:\mingw completo\mingw-mingw-w32api\include\winsock2.h 83 C:\progc\ifdef.c from C:\progc\ifdef.c 2398 2 C:\mingw completo\mingw\include\winnt.h [Error] #error "undefined processor type" 2401 1 C:\mingw completo\mingw\include\winnt.h [Error] unknown type name 'CONTEXT' 62 0 C:\mingw completo\mingw\include\windows.h In file included from C:\mingw completo\mingw\include/windows.h 22 C:\mingw completo\mingw-mingw-w32api\include\winsock2.h from C:\mingw completo\mingw-mingw-w32api\include\winsock2.h 83 C:\progc\ifdef.c from C:\progc\ifdef.c 1733 1 C:\mingw completo\mingw\include\winbase.h [Error] unknown type name 'CONTEXT'
mi codigo es este:
Código
#include <stdio.h> #include <stdlib.h> #include <winsock2.h> #include <windows.h> #define PORT 3550 #define BACKLOG 2 main() { WSADATA wsaData; if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0 ) { return 0; } int fd, fd2; struct sockaddr_in server; struct sockaddr_in client; int sin_size; if ((fd=socket(AF_INET, SOCK_STREAM, 0)) == -1 ) { } server.sin_family = AF_INET; server.sin_port = htons(PORT); server.sin_addr.s_addr = INADDR_ANY; if(bind(fd,(struct sockaddr*)&server, sizeof(struct sockaddr))==-1) { } if(listen(fd,BACKLOG) == -1) { } while(1) { sin_size=sizeof(struct sockaddr_in); if ((fd2 = accept(fd,(struct sockaddr *)&client, &sin_size))==-1) { } inet_ntoa(client.sin_addr) ); send(fd2,"Bienvenido a mi servidor.\n",22,0); close(fd2); } WSACleanup(); }