Introduction to TCP/IP and Sockets, part 2: Example code Walk-Through

  Рет қаралды 21,189

Rhymu's Videos

Rhymu's Videos

Күн бұрын

This is a walk-through of example C++ code for using Sockets to send and receive messages between programs using the Internet protocols.
This is part 2 of the series. Part 1 is here: • Introduction to TCP/IP...
Here is a link to all the code: github.com/rhymu8354/SocketTu...
Index for skipping to the sections you care about:
00:00 - Introduction
01:55 - Downloading the tutorial/example code
02:28 - Opening and building in VSCode
03:52 - Running the TCP server example
04:24 - Modifying TCP client example to run it to connect to TCP server
05:16 - Running the TCP client example
05:38 - Showing TCP client/server exchange using WireShark
09:28 - Running the UDP receiver example
09:49 - Running the UDP sender example (after setting correct IP address)
11:27 - Showing UDP sender/receiver exchange using WireShark
12:15 - Code walk-through begins
12:45 - Sender program (UDP)
13:41 - Receiver program (UDP)
15:16 - DatagramSocket class (UDP, shared by Sender and Receiver programs)
22:50 - Explanation of the 3 common results from socket I/O
25:02 - Differences between POSIX Sockets and WinSock
27:45 - Usage of mutexes to allow asynchronous operations to be thread-safe
28:47 - Rule about not holding mutexes when calling callbacks (to avoid deadlocks)
29:59 - Warning to not assume that it's still safe to access the same state after releasing and then reacquiring a mutex
30:43 - General coding pattern: Pimpl (pointer to implementation)
31:19 - General coding pattern: C++ rule of zero/three/five
33:07 - Client program (TCP)
35:26 - Server program (TCP)
39:03 - Callbacks for when data is received or the connection is closed
40:58 - ClientSocket class (TCP, used by Client program)
43:40 - ServerSocket class (TCP, used by Server program)
47:28 - ServerSocket::Client class (client-server state object)
47:53 - Connection class (TCP, shared by ClientSocket and ServerSocket)
53:25 - O/S abstractions: UsesSockets (WinSock startup/cleanup helper)
54:52 - O/S abstractions: SocketEventLoop (asynchronous socket I/O)
If you would like to see more information on setting up CMake and C/C++ to work with VSCode, this video covers these topics in more detail: • Introduction to Google...

Пікірлер: 24
@alokbishoyi1911
@alokbishoyi1911 4 жыл бұрын
I just want to let you know how much I appreciate your efforts ! And you have been going at it for such a long time. Literal angel!
@rhymu
@rhymu 4 жыл бұрын
Thank you very much!
@sylvanaswindrunner1141
@sylvanaswindrunner1141 3 жыл бұрын
The best socket code walk-through in c++, very clear, thanks a lot !
@adamkrawczyk6600
@adamkrawczyk6600 4 жыл бұрын
Thank you for adding those videos, keep going. Many times I’ve used your knowledge ;)
@rhymu
@rhymu 4 жыл бұрын
My pleasure!
@grant9942
@grant9942 3 жыл бұрын
Great videos and explanations! Please keep up the good work!
@tuhinmukherjee8141
@tuhinmukherjee8141 3 жыл бұрын
Hey, I'm a networking novice. Your two-part video series was the best playlist I found on the internet. Thanks for doing this Sir!
@reverse_shell
@reverse_shell 4 жыл бұрын
Rhymu, this video packs a punch! There is so much going on and I would have liked to see sending an object over the wire as opposed to just text. Something like a JSON data object would be really neat. Overall this was just a wealth of knowledge and presented with essentially a boiler plate library wrapped neatly with a bow.
@rhymu
@rhymu 4 жыл бұрын
That is awesome feedback; thank you! If I update this series I will definitely include examples showing objects and their serialization over the wire.
@reverse_shell
@reverse_shell 3 жыл бұрын
@@rhymu If I beg will you make a 3rd video? :)
@NalinKanwar
@NalinKanwar 3 жыл бұрын
Such a nicely written platform independent client/server code! :)
@geledek573
@geledek573 Жыл бұрын
This is the best explanation video i've seen in youtube. ❤
@placiduzzu
@placiduzzu 7 ай бұрын
Excellent code quality. Thank you!
@iosd_Halif
@iosd_Halif Жыл бұрын
Thanks a lot, Rhymu!!!
@filmont5246
@filmont5246 3 жыл бұрын
Waw it was amazing. I have a project relating to this topic and after all my search on youtube, I find this useful video. But it was more on the programming you focused, it would be amazing if you could do some Wireshark tests in the middle. Anyway, it was nice thanks.
@zxcghoul1275
@zxcghoul1275 2 жыл бұрын
thanks exelent course
@shervinrad100
@shervinrad100 3 жыл бұрын
I cant see how anyone could have done this explanation any better
@samantha4508
@samantha4508 Жыл бұрын
thank you! bye 👋
@kenwilliams6788
@kenwilliams6788 2 жыл бұрын
Thank you for this video! Might be a dumb question, but do you have different machines for Server and Client? (around min 5:20) From the same machine I get "error: unable to connect "
@rhymu
@rhymu 2 жыл бұрын
Yes, I had them running on two separate computers on the same local area network. You can get it to work from the same machine, if you adjust the IP address you use, to make sure it's an IP address on the same machine. An IP address of "127.0.0.1" (0x7F000001) on most machines works as a "loopback" address.
@lGGMasterl
@lGGMasterl 2 ай бұрын
@@rhymu pasaron muchos años , pero necesito hacerle una pregunta (no hablo ingles asique capas lo comento en el video) yo tengo un chat cliente servidor que funciona en mi misma computadora , pero cuando intento conectar mi cliente desde otra computadora en la misma red simplemente el server no obtiene la conexion del cliente , cual podria ser el error ? ya probe desactivando el firewall y nop , aclaro que el server esta en win 10 y el cliente en Kali linux quizas tenga algo que ver con los sistemas operativos ?
@rhymu
@rhymu 2 ай бұрын
@@lGGMasterl Jag talar inte spanska så jag var tvungen att använda Google Översätt för att förstå din fråga. Så jag ska använda det igen för att göra mitt svar till ett tredje språk som du förmodligen inte kan, för att ge tillbaka tjänsten. Jag önskar att du hade lämnat mer information om vad du har provat, eller kanske en länk till din kod. Utan dessa kan jag bara gissa vad som kan vara fel. När du binder serverporten, använder du en jokerteckenadress som 0.0.0.0 för att den ska lyssna på anslutningar från alla nätverksgränssnitt? Har du testat att använda "netstat" för att se om din server faktiskt lyssnar och på vilka lokala/utländska adresser/portar? Har du testat att använda Wireshark för att se om din klients anslutningsförfrågningar gör det till nätverket, eller om servern överhuvudtaget svarar på dessa förfrågningar?
@lGGMasterl
@lGGMasterl 2 ай бұрын
@@rhymu buenas tardes , muchas gracias por responderme y dedicarle tiempo. alfinal mi error fue no utilizar la IP correcta , me volvi loco buscando respuestas y fue algo tan simple como cambia de IP , anteriormente ya lo habia intentado pero resulta que debia introducir una de un adaptador de red que tengo , de todas formas muchas gracias por leerme.
@animetexture7564
@animetexture7564 Ай бұрын
How do you handle multiple connection?
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 41 М.
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 8 МЛН
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 498 М.
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 23 МЛН
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 95 М.
Creating a TCP Server in C++ [Linux / Code Blocks]
43:15
Sloan Kelly
Рет қаралды 85 М.
How to write a multithreaded server in C (threads, sockets)
14:30
Jacob Sorber
Рет қаралды 131 М.
TCP Fundamentals Part 1 // TCP/IP Explained with Wireshark
1:17:24
Chris Greer
Рет қаралды 420 М.
How TCP really works // Three-way handshake // TCP/IP Deep Dive
1:01:10
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 152 М.
The Linux socket API explained
15:21
Chris Kanich
Рет қаралды 32 М.
OSI and TCP IP Models - Best Explanation
19:20
_Drunk Engineer_
Рет қаралды 306 М.
Basics of UNIX Sockets - Screencast by Mischa Spiegelmock
52:46
JetBridge - Elite Software Devs
Рет қаралды 18 М.
Что не так с яблоком Apple? #apple #macbook
0:38
Не шарю!
Рет қаралды 475 М.
Неразрушаемый смартфон
1:00
Status
Рет қаралды 2,3 МЛН
Blue Mobile 📲 Best For Long Audio Call 📞 💙
0:41
Tech Official
Рет қаралды 1 МЛН
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 170 М.