socket programming for windows in C
hi guys,
I'm still learning C, and although socket programming for linux works like a charm, i can't get it to work for windows....
the code that is given in this tutorial is supposed to be written for Visual C++ 6.0 standard edition, well i have it too...
if i try to compile this code i get the following errors:
Quote:
--------------------Configuration: winsock - Win32 Debug--------------------
Compiling...
winsock.c
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(11) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(12) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(13) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(14) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(22) : error C2065: 'sockfd' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(27) : error C2065: 'h' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(27) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct hostent *'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(27) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(33) : error C2065: 'server' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(33) : error C2224: left of '.sin_addr' must have struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(33) : error C2223: left of '->h_addr_list' must point to struct/union
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(34) : error C2224: left of '.sin_port' must have struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(35) : error C2224: left of '.sin_family' must have struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(43) : error C2065: 'message' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(43) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(43) : warning C4024: 'send' : different types for formal and actual parameter 2
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(43) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
C:\Program Files\Microsoft Visual Studio\MyProjects\winsock\winsock.c(43) : warning C4024: 'strlen' : different types for formal and actual parameter 1
Error executing cl.exe.
winsock.exe - 12 error(s), 6 warning(s)
i've tried several other tutorials about sockets in windows, but none of them will compile, most give errors about the functions used in winsock.h.
i've tried different compilers too:
Dev-C++
Pelles C
Borland C++
but i can't compile any sources which contain sockets in windows.
how is this possible, and better, how should i solve this, it's getting really irritating, i've been strugling with this problem for a couple of weeks now, have read all i could about sockets in windows, added WSock32.lib to the project, but that still gives errors :(
any help is greatly appreciated!