Hello. I have been learning C++ for a while now. I know how to create C++ Console applications, and im wondering if theres any good tutorials on using Sockets/Winsock2 in C++ Console apps.

Please don't say I should learn Windows API, or MFC, I already know about those, and I will eventually get to WinAPI. But most of the tutorials I find on the internet either use Visual Basic, or Windows API/MFC with sockets.

If the Beej's sockets tutorial (Uses unix) using the extra windows thing it says in the tutorial will work with C++ Console apps, please tell me... Thanks!

P.S Can you try and tell me about Winsock2 instead of just Winsock, I've heard Winsock2 is better and more advanced.

Comments
I'm seeing red now for sure :(

Oh im sorry about the bold bright text and stuff in my post!! I didn't know about that rule, ill be more carefull next time...

Anyway, thanks ill check that link out!

Well I just looked at that link, and it only shows using sockets with Window API/MFC. Im looking for one that is compatible for using in a C++/C console application, not Windows apps.

You can still use the windows API in your console application. There is no standard sockets implementation. So you need to use API calls, be it Win32 or POSIX.

Chris

winsock IS part of win32 api. If you are looking for more complex client/server console code then you can find it by downloading the library here

>>No Windows API is different. Console applications are the DOS window.
You don't have to write a windows program to implement some win32 api functions.

Comments
Thank god i'm not alone

What about Unix Sockets. It says to run on Windows theres things in it that you have to change/add, but will a C++ DOS Console app run normal unix sockets under windows normally without the changes?

Oh, so can I use the Console lib under a windows app, and then use sockets with that? Or is my other comment I just replyed with true?

DOS != UNIX therefore they are different. Therefor they need different sockets. *Win*sock is the windows socket libraries, implemented with Win32 API calls, which CAn be used with DOS console applications but NOT unix.

Chris

Lol I know thats what I was trying to say and ask... So for sure, I can go into Dev C++ (The Compiler I use), select new project >> console app (instead of windows app) >> then create a C++ app using the C++ Console lib, and the Winsock2 library? If thats what you just said, Thanks!!! Finally my question is answered in this post, sorry about the long and rambling post...

So for sure, I can go into Dev C++ (The Compiler I use), select new project >> console app (instead of windows app) >> then create a C++ app using the C++ Console lib, and the Winsock2 library?

Everyone has told you that about a million times now :)

No Windows API is different. Console applications are the DOS window.

Actually they're just Window console apps, using the command prompt. They're not true DOS programs, unless you have a compiler compiling for DOS.
I think you're just confusing the OSes with command prompt.

This article has been dead for over six months. Start a new discussion instead.