C++ Network Programming Part 1: Sockets

Sdílet
Vložit
  • čas přidán 8. 07. 2024
  • Part 1 on Sockets: • C++ Network Programmin...
    Part 2 on TCP and UDP: • C++ Network Programmin...
    0:00 Introduction
    0:58 Introduction to WinSock
    3:06 OSI Model
    7:25 Client-Server Architecture
    9:20 IP Addresses
    13:26 Ports
    16:12 Creating a Socket Illustration
    23:47 Seven Steps of a Server
    24:56 Five Steps of a Client
    25:57 Server Step 1 - Load DLL
    32:52 Server Step 2 - Create Socket
    39:25 Server Step 3 - Bind Socket
    47:23 Server Step 4 - Listen
    50:54 Server Step 5 - Accept
    55:13 Client Step 3 - Connect
    1:01:38 Exercise - Setting up the Server
    1:09:19 Exercise - Setting up the Client
    1:12:41 Exercise - Connecting Client and Server

Komentáře • 67

  • @zecuse
    @zecuse Před 2 měsíci +6

    For anyone wondering, AF_INET is for IPv4 type addresses not TCP or UDP. AF_INET6 is used for IPv6 addresses. Only the _type_ parameter of the socket function is responsible for determining if it will be TCP or UDP.

  • @stainie
    @stainie Před 5 měsíci +24

    This series alone is worth more than a bunch of paid Udemy courses. Thank you Nicholas for sharing your knowledge!

    • @smizal4834
      @smizal4834 Před 5 měsíci +4

      Yeah, for sure. This guy deserves millions

  • @holesmak
    @holesmak Před 2 lety +46

    this is pure gold. Havent watched to the end yet but it gives a lot of understanding on the subject in c++

  • @samuelsantoshernan5093
    @samuelsantoshernan5093 Před rokem +8

    Oh, my god. This channel deserves infinitely more suscriptors. Perfectly well explained such a difficult topic!
    Thank you so much for this!

  • @iNFiNiTY-yf3rk
    @iNFiNiTY-yf3rk Před rokem

    Waiting for part 2! It's such a great video tbh. Best one about this topic

  • @paulmathew1214
    @paulmathew1214 Před rokem +5

    Great video! I have previously done work with sockets in python but wanted to learn how to do it in c++ and this tutorial was perfect! Easy to understand and gave me the fundamentals to do what I want.

  • @Darthrein
    @Darthrein Před 27 dny

    This series is seriously underrated for such a high quality explanation!

    • @NicholasDayPhD
      @NicholasDayPhD  Před 24 dny

      Thank you so much - glad this material helps you!

  • @paolocherubini6536
    @paolocherubini6536 Před 2 lety +17

    Socket is a tricky issue and you explained It very well. Thank you for your pronunciation that sounds perfect to an italian native speaker.

  • @virtualsocialretreat8234

    this was super entertaining and informative, even though it's in a language i don't use. subscribed

  • @Saleh_Mohammd
    @Saleh_Mohammd Před 8 měsíci +2

    Thanks bro, clean voice, clean code❤

  • @Danny-ck6iw
    @Danny-ck6iw Před 2 lety +1

    Great video, easy to understand. Thank you very much

  • @mersenne2486
    @mersenne2486 Před 10 měsíci +1

    awesome lecture

  • @RealCatDev
    @RealCatDev Před 7 měsíci

    Seems interesting. Fortunately I want to implement networking for my games and engine in a short future

  • @winuxworx
    @winuxworx Před rokem +2

    Can you please share the document reference you are using in the video?

  • @SaintMorning
    @SaintMorning Před rokem +6

    Thank you for hosting all your lectures. Your lessons are very awesome.
    I think using: using namespace std
    Is in general not good because of namespace cluttering
    Thank you so much for your lessons!! truly appreciated.

    • @NicholasDayPhD
      @NicholasDayPhD  Před rokem +5

      Very kind of you to write this feedback - noted for future!

  • @scienceandengineering3827

    very great

  • @robn2497
    @robn2497 Před 2 měsíci

    After 2hours typing all the code in manually, it worked :)

  • @mafi_tube
    @mafi_tube Před rokem

    Thank you for sharing this very good lecture!
    One question please, @37:40 don't we need the shutdown() function before calling the WSACleanup() and before calling the closesocket()?

  • @hicham2668
    @hicham2668 Před 11 měsíci +1

    Crystal clear, thank you so much🙏

  • @amortalbeing
    @amortalbeing Před 3 měsíci

    Thanks a lot

  • @osmanemredonder3604
    @osmanemredonder3604 Před rokem

    Hello, I would like to ask if other computer can connect to that server and send binary text?

  • @aryanab3292
    @aryanab3292 Před 8 měsíci

    Nice!

  • @ragdoll_physics
    @ragdoll_physics Před 2 lety +4

    Ah, I wish you had done the presentation using a UNIX environment but nonetheless the explanation was superb and it was very useful for me. Thanks and bless you.

    • @NicholasDayPhD
      @NicholasDayPhD  Před rokem +2

      Thanks so much - it's not too difficult to get this working in a UNIX environment. The functions should be the same!

  • @emersondejesusgrandatilano3427

    hello i was wondering about where i can find that word document where is all the step by step plss

  • @amandojuarez8216
    @amandojuarez8216 Před 2 lety +7

    Hello sir, I was wondering how you added the two header files(stdafx.h & targetver.h)? I cant seem to figure it out on visual studio 2019

    • @tyasto6024
      @tyasto6024 Před 4 měsíci

      Did you add them ? if yes, how please

  • @chaoyin1263
    @chaoyin1263 Před rokem

    Thank you so much for these videos!! But I do not know where can I find your word document. 😭

  • @uanbu6539
    @uanbu6539 Před rokem +3

    Where can I download the stdafx.h header file????

  • @kennethmanheim265
    @kennethmanheim265 Před rokem

    1:01:53 How do i do this on different Machines?

  • @refuro
    @refuro Před 2 lety +2

    Thank you for making this video. Is there any way you can link the project files in the description? I also have maybe a somewhat naive question, but since we are using windocks, I'm assuming it's meant for windows. Will this also be compatible with linux-based Operating systems? Have a great day!

    • @NicholasDayPhD
      @NicholasDayPhD  Před 2 lety +2

      Hi there, yes, I have managed to code this on a Mac too (and confident it would be similar for Linux). The functions such as socket(), bind(), listen(), connect(), accept(), send(), recv() etc are the same for both Windows and Mac. Main differences are the low level Windows types (such as DWORD) are substituted for strings and integers with Mac. And rather than libraries winsock2.h and ws2tcpip.h, there are equivalent libraries such as arpa/inet.h, netdb.h, sys/socket.h, sys/types.h and unistd.h for Mac solutions.

    • @raghuvaranpothuganti
      @raghuvaranpothuganti Před 2 lety

      @@NicholasDayPhD Hi Thank you very much for the detailed lectures. Would you please help me providing the info on how can we implement these in mac. Because we need two processes server and client, can we achieve this in mac terminal or do we need any IDE?

    • @NicholasDayPhD
      @NicholasDayPhD  Před 2 lety

      @@raghuvaranpothuganti I've managed to run similar code via the IDE Visual Studio Code (to compile the source C++ code in to an executable application). You can also get Visual Studio for Mac, or you may even prefer the IDE CLion by JetBrains (same developers of IntelliJ). Basically, you just need an IDE to compile the source code! Once compiled, clicking on the application will launch a terminal window. For this basic example, I had two terminal windows on the the same Mac (one for server, one for client). However, you could configure the applications to talk to each other across a network. Hope that helps...

    • @abderrahmanechahdane4814
      @abderrahmanechahdane4814 Před rokem

      @@NicholasDayPhD i guess you don't need the initialize WSA part, in linux based systems right ?

  • @kpfxzzsy
    @kpfxzzsy Před 5 měsíci

    thank you, could you take another video in c#, I very need it.

  • @nikhilt3755
    @nikhilt3755 Před 4 měsíci +3

    37:00 af_inet refers to ipv4, not tcp or udp.
    af_inet6 refers to ipv6.

    • @d4sty.
      @d4sty. Před 2 měsíci

      so how do i know if the client uses ipv6 or ipv4??? does it still connect you if you are on a different one?

  • @rajeshbnarasimha934
    @rajeshbnarasimha934 Před 10 měsíci

    Hi Mr. Day, I have encountered an error on codeblocks, and I have included all the supporting files u mentioned but compiler says, "InePton was not declared....." Could you please get me through this..

    • @liquidatedrice5274
      @liquidatedrice5274 Před 7 měsíci +1

      Putting "#define _WIN32_WINNT _WIN32_WINNT_VISTA" before "#include " and "#include " worked for me. This means Windows Vista is the oldest OS your code will work on though.

    • @ShirChoi
      @ShirChoi Před 7 měsíci

      Did you find the answer for you question? I am facing the same problem rn and can't find the answer

    • @rajeshbnarasimha934
      @rajeshbnarasimha934 Před 7 měsíci

      @@ShirChoi this series gives u a good outlook of what socketprogramming is. However, it doesn't work on codeblocks. I would recommend czcams.com/play/PLhnN2F9NiVmAMn9iGB_Rtjs3aGef3GpSm.html&feature=shared

  • @Morteza7220
    @Morteza7220 Před 6 měsíci

    👏👏🙏

  • @learningdatasciencealongme190

    Where can we find notes sir ?

    • @NicholasDayPhD
      @NicholasDayPhD  Před 2 lety +2

      Hi there - the notes for this course are based on Lippman's book on C++. Here is a simplified tutorial that may help: www.geeksforgeeks.org/socket-programming-cc/

  • @MalamIbnMalam
    @MalamIbnMalam Před 8 měsíci +1

    I assume that this would be similar to network programming with C++ in Linux

  • @tuti8452
    @tuti8452 Před rokem

    please share word document

  • @syedzainalishah749
    @syedzainalishah749 Před rokem

    well explained please can you send me PPT lectures

  • @hardbrocklife
    @hardbrocklife Před rokem

    Another source code tutorial I found uses int LISTENONPORT(int portno) as its entry point. Why, and why does this source code seem to loath my existance lol? Python is just like "Do socket stuff on X socket" and it just goes.

  • @deveep339
    @deveep339 Před 4 měsíci

    why would you make it white its so bright my developer eyes cant handle this

  • @Tech_Code127-76
    @Tech_Code127-76 Před 5 měsíci +1

    Why don't you just dive right in? Some of us hate "theory" just explain things while you code! Otherwise great video!

    • @kidkyle712
      @kidkyle712 Před 4 měsíci +1

      Because that's stupid. "Diving right in" just encourages people to type over and barely learn anything. It's important to understand the concepts you're going to implement before actually implementing them.

  • @duydug9967
    @duydug9967 Před 6 měsíci +1

    uhm, i don't know.
    i am a person who don't like long video ;-;

  • @zenith_tetris
    @zenith_tetris Před rokem

    Hey, where can I find the word document?

  • @sss-og7jx
    @sss-og7jx Před 2 lety +3

    really like your c++ series! I would like to know where can I get stdafx.h and targetver.h files.

    • @NicholasDayPhD
      @NicholasDayPhD  Před 2 lety +2

      Thank you so much! You can find them with older C++ projects. Should be freely available on the internet.

  • @Wolf-ts9gl
    @Wolf-ts9gl Před 10 měsíci

    Does someone know where I can find the files "stdafx.h" and "targetver.h" ? I found them on Github but my IDE can't find the files afxwin.h, afxext.h, etc. Thanks for helping me...

    • @mersenne2486
      @mersenne2486 Před 10 měsíci +1

      you don't need any of those you can run your programs without those