Page 1 of 11

C++ Winsock Networking Tutorials [04-24-2017]

Posted: February 22nd, 2016, 6:22 am
by Pindrought
Note: Topic will be updated each time thread is updated.

Link to Tutorial Playlists

[Beginner Winsock Networking with Blocking Sockets]: https://www.youtube.com/playlist?list=P ... 7NzSlxlTKx

[Winsock Nonblocking Sockets]: https://www.youtube.com/playlist?list=P ... XR7-DDCNbX

Tutorial 1
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=AjG4jcVn6QE
Description:
How to create a server and a client.
How to connect to a server with the client.
How to receive 256 character message from server as the client.

Solution Link: http://www.mediafire.com/download/6i36x ... rial_1.rar
Tutorial 2
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=Plv7QdLkNQk
Description:
How to extend server to allow more than one client.
Allow clients to send messages to each other.

Solution Link: http://www.mediafire.com/download/brew8 ... rial_2.rar
Tutorial 3
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=YPCpUz5nTK0
Description:
How to change server and client to be able to process messages that are not exactly 256 characters (256 bytes) in size.

Solution Link: http://www.mediafire.com/download/d38ls ... rial_3.rar
Tutorial 4
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=Yz275L8HRts
Description: Set up the client and server to be able to process different types of packets.
Solution Link: http://www.mediafire.com/download/aozt1 ... rial_4.rar
Tutorial 5
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=wqRdELNi3z4
Description: Set up functions for receiving packet, int, and string and for sending packet, int and a string. Be able to check if there is a connection issue.
Solution Link: http://www.mediafire.com/download/628dr ... rial_5.rar
Tutorial 6
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=hyNF3m-JlN4
Description: Create Client and Server class to make the program more object oriented. Also adding more error checking for when things go wrong.
Solution Link: http://www.mediafire.com/download/g48be ... rial_6.rar
Tutorial 7
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=wkTwx4FOElg
Description: Handling partially sent/received packets.
Solution Link: http://www.mediafire.com/download/gcd4n ... rial_7.rar
Tutorial 8
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=Utq5KYf ... e=youtu.be
Description: Big Endian vs Little Endian - What is it and how to handle it?
Solution Link: http://www.mediafire.com/download/5dab8 ... rial_8.rar
Tutorial 8 Fix
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=n4Clp-7HX5M
Description: Reviews fix made to Tutorial 8.rar that I forgot to include in the video. Applies endianness that we learned in Tutorial 8 to the Send/Get Packet Type functions.
Tutorial 9 Pre-Tutorial Review
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=DZ3g3FV9wQo
Description: Reviews how to read/write from binary files using std::ifstream and std::ofstream and how to copy a file using these techniques. These will be used in Tutorial 9 for sending a file from the server to the client.
Tutorial 9
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=9jLhDYtyA7c
Description: How to send a file from the server to the client?
Solution Link: http://www.mediafire.com/download/wpzj6 ... rial_9.rar
Tutorial 10 Pre-Tutorial Review #1 (Linked Lists)
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=JoqW88fNDCU
Description: Reviews a brief summary over how to use linked lists. We will use these in tutorial 10 when we begin implementing a packet manager to synchronize our outgoing packets.
Solution Link: http://www.mediafire.com/download/7836e ... ration.rar
Tutorial 10 Pre-Tutorial Review #2 (Mutexes)
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=aN--UP7 ... e=youtu.be
Description: Reviews a brief summary over how to use mutexes. We will use these in tutorial 10 when we begin implementing a packet manager to synchronize our outgoing packets.
Solution Link: http://www.mediafire.com/download/ottqm ... ration.rar
Tutorial 10 Pre-Tutorial Demonstration (Vector vs Linked List Speed)
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=jEOxIgbtSLQ
Description: Demonstrates the speed difference in using a vector of packets and a linked list of packets.
Solution Link: http://www.mediafire.com/download/7ddsg ... ration.rar
Tutorial 10 Pre-Tutorial Demonstration [Fixed] (Vector vs Linked List vs Queue Speed)
Spoiler:
Youtube Link: https://youtu.be/GEYrVhaD08I
Description: Demonstrates the speed difference in using a vector of packets, linked list of packets, and a queue of packets.
Solution Link: http://www.mediafire.com/download/7ddsg ... ration.rar
Tutorial 10
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=Yxvri-W ... e=youtu.be
Description: Implementing packet manager into server.
Solution Link: http://www.mediafire.com/download/zlco4 ... ial_10.rar
Tutorial 11
Spoiler:
Youtube Link: https://youtu.be/Ut6pi9ZmrVU
Description: Change server to use a vector of connections to allow more than 100 connections at once and address the issue of sending data to users that have already disconnected. (Note: Server most likely wont be able to handle that many clients properly using blocking sockets - this will be addressed later)
Solution Link: http://www.mediafire.com/download/7kd6y ... ial_11.rar
Set up server to have other people connect
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=xikq1pO ... 7NzSlxlTKx
Description: Explains how set up server/client so that other computers on router can connect or other computers from remote locations can connect to your server.
Solution Link: None
Tutorial 12
Spoiler:
Youtube Link: https://youtu.be/be09jpq0Mlw
Description: Modify server to use packet manager to send files.
Solution Link: http://www.mediafire.com/file/011yhs11b ... ial+12.rar
Tutorial 13
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=zdQDHCjJ7YQ
Description: Many changes. Client now uses packet manager, changed how packet manager works to use shared_ptr of Packets, changed how packets worked to use vector of bytes instead of a char * to the buffer, cleaned up code, added m_ prefix to member variables, used const where applicable, changed from CreateThread to std::thread, no longer using deprecated functions, removed unnecessary includes, using shared_lock now for packetsender and processpacket, no longer using strange connection management, etc.
Solution Link: http://www.mediafire.com/file/cx1mxfl0f ... ial_13.rar

NONBLOCKING TUTORIALS LISTED BELOW

Tutorial 1
Spoiler:
Youtube Link: https://youtu.be/M4VFJ0hxPDg
Description: Create basic nonblocking server that can accept connections and attempts to receive 4 bytes of data and display the data using std::cout. Can also handle if a client disconnects. Only utilizes the readfds FD_SET.
Solution Link: http://www.mediafire.com/file/y19zuyfe6 ... rial_1.rar
Tutorial 2
Spoiler:
Youtube Link: https://youtu.be/2Sb359eZdWA
Description: Add write and except FD_SET's and handling for them.
Solution Link: http://www.mediafire.com/file/oe9k5wq44 ... rial_2.rar
Tutorial 3
Spoiler:
Youtube Link: https://youtu.be/ldS885D97ZU
Description: Create nonblocking client. [Note: Client does not handle if server loses connection, but will be addressed in tutorial 3.5]
Solution Link: http://www.mediafire.com/file/wov8fs80v ... rial_3.rar
Tutorial 3.5
Spoiler:
Youtube Link: https://www.youtube.com/watch?v=9zB_xb9SleQ
Description: For nonblocking client simulator, add functionality to detect if connection is lost to the server.
Solution Link: http://www.mediafire.com/file/v2f88hjdq ... al_3.5.rar
Tutorial 4
Spoiler:
Youtube Link: https://youtu.be/P1fLN6AKLPE
Description: Add handling for partial send/recv's, add TCPConnection class to store information about the current connection. Briefly review the process for how we will be handling sending/recv'ing differently on nonblocking on blocking.
Solution Link: http://www.mediafire.com/file/t5xght6gp ... rial_4.rar

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 3:23 pm
by adabo
Will definitely be keeping an eye on this. Thank you kindly!

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 3:47 pm
by adabo
Hmm, so I just watched the first tut and I'm wondering, is winsock what we use to send data in multiplayer games? I have no idea about networking, so I'm at your mercy of knowledge.

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 4:34 pm
by Pindrought
adabo wrote:Hmm, so I just watched the first tut and I'm wondering, is winsock what we use to send data in multiplayer games? I have no idea about networking, so I'm at your mercy of knowledge.

Winsock is a library used to send data over sockets for Windows platforms, so to answer your question yes. You will want to use a different networking library however for linux or apple systems since I don't think Winsock is cross platform.

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 6:54 pm
by LuisR14
but winsock contains functions that are cross platform, ..actually, winsock has its own functions which the cross platform functions are equivalents of

(pretty much you can create same app with such functions, only exception is those WSAStartup and WSACleanup functions, which is easy to exclude for non-windows apps anyways)

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 6:56 pm
by adabo
Oh wow, really? So windows games like Call of Duty, Age of Empires, WoW, all use winsock?

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 7:14 pm
by LuisR14
yea most likely :)

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 7:15 pm
by Pindrought
LuisR14 wrote:but winsock contains functions that are cross platform, ..actually, winsock has its own functions which the cross platform functions are equivalents of

(pretty much you can create same app with such functions, only exception is those WSAStartup and WSACleanup functions, which is easy to exclude for non-windows apps anyways)
Thanks for the clarification LuisR14. I wasn't really sure myself of how it worked when it came to cross platform implementations.

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 7:18 pm
by LuisR14
no problemo :)

Re: C++ Winsock Networking Tutorials [2-22-2016]

Posted: February 22nd, 2016, 8:38 pm
by MrGodin
Hey, nice to see you doing these again :). I have a question, does the lib work on x64 or do you need a different lib ?.