William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
Just google for "beej".
It's a widely quoted tutorial.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
You could try posting your code AND error messages.
Do you expect your doctor to come up with accurate diagnoses when all you can manage to say is "it hurts" ?
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
I mean the linkers it tells me to put in dont even work with the GNU GCC Compiler in codeblocks.
Excuse me?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
Consider this to be the flavour of the problem rather than an answer (I don't have code blocks on this machine).
In the project settings, there should be a tab to configure the linker. Here you can tell the linker the places where to find other libraries, and the names of those libraries. It may already have the "standard set" of libraries already listed.
What you need to add to that is the name of the winsock library, which IIRC is called ws2_32.lib
Dev-C++ for example calls it libws2_32.a, so feel free to search for likely looking names ending in .lib or .a.
If code blocks follows the standard library naming convention, then libws2_32.a will simply be called ws2_32 on the linker command line.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Well your wsa startup is a random bit of code not in any function, and mis-matched braces as well.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
How you order the code (all inline in main, lots of functions ) is entirely up to you.
But I'd go with
int main ( ) {
// do wsa startup here
// call function to do the entire network session
// do wsa cleanup here
}
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953