Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Winsock C++ Tutorial part 1 of 2

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
29,767
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 11, 2008

Here's how to make a simple Socket class to use Winsock with C++. This isn't really sufficient for a chat program, but it's a start. Will have more later.

I don't currently know much about Winsock, so annotations will be added as I figure more stuff out, or find bugs in the program.

Download source and exe from here:
http://moosader.deviantart.com/art/C-Winsock-Sample-Program-97696619

Part 1:
http://www.youtube.com/watch?v=w5MPIkveJoQ
Part 2:
http://www.youtube.com/watch?v=AVyKZeOZnzk

Category:

Howto & Style

Tags:

License:

Standard YouTube License

  • likes, 7 dislikes

Link to this comment:

Share to:

Uploader Comments (LusikkaMage)

  • What's the point of the SendData() function? It returns true - but it always returns true no matter if send() failed or not, why is it not checked?

    if( send( ... ) != SOCKET_ERROR )

    return true;

    else

    return false;

    ??? I have to say I first was positive about this tutorial and thought it was better than those out there in the internet but I get disappointed more and more..

  • @mySaigaAntilope It was pretty incomplete, yes. I'm sorry for the quality, it is quite old, and back then it was hard to get anybody to peer review my tutorials. Hopefully what I release in the future will be better quality, once I have time again to make tutorials (really busy w/ full time software engineering jobs since I've been out of college).

  • iostream? lol. I use conio and stdio

  • @vitorix24 So you're writing C code and not C++ code.

  • @LusikkaMage It's just libraries. C and C++ it's almost same thing. =D

  • @vitorix24 No no no no no no no. C++ is much more than an extension of libraries on top of C. C++ is a completely different language, and while C is compatible with C++, C++ is not compatible with C.

    C++ is a multi-paradigm language, so on top of your basic C functionality it also includes Object Oriented designs as well as Templating.

    Polymorphism, Encapsulation, Inheritance, all are parts of C++ that are not parts of C, and using C++ with only C functionality is a waste of the language.

Top Comments

  • it never ceases to depress me how little i know.

see all

All Comments (79)

Sign In or Sign Up now to post a comment!
  • How would I add libws2_32.a to visual studios 2010? It's a linker file, yes?

    I'm getting these weird errors that consist of " 1>Socket.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function "public: __thiscall Socket::Socket(void)" (??0Socket@@QAE@XZ)"

    and whatnot

  • I got a question

    I got the code and it works, and now I want to have that client window on an other laptop, for now I want a LAN connection but how can I do that?

    I gave my both laptops their own IP adress, but my still can't find the host ;(

    Do you know how to make that LAN network?

  • Please show us a (or is it an?) UDP example!

  • I'm using winsock and it randomly puts winsock 2.0 with a bunch of smiley faces in the data i send..........................­..... wtf

  • One thing I haven't gotten with Winsock, is getting it to run over a WAN. On my home network it ran fine., but I once tried to get it to work over internet, and it didn't work. Also file transfer is something I haven't gotten to.

  • @LusikkaMage What's your thought on C99?

  • @vitorix24 get your facts right ^^

  • @farmdve She's a 23-years-old female, as you can see in her profile.

    But anyway, i have to see i saw the tutorial relative to this video, in written text.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more