🌐 Network Programming in Rust - Building a TCP Server

Sdílet
Vložit
  • čas přidán 23. 07. 2024
  • 📺 Welcome to another exciting Rust programming tutorial!
    In this video, we'll explore the fundamentals of networking in Rust by building a simple TCP server. We'll walk you through the code snippet provided, explaining each key component and step along the way. Let's get started!
    ⚠️ It’s very easy to help the channel ⚠️
    ➊ Like 👍 or 👎 the video
    ➋ Write a comment 💬 under the video (I answer almost everyone)
    ➌ Send video ✉️ to friends via social networks
    ➍ Watch the rest of the videos 🎥 on the channel.
    ✔️Every completed item makes the channel better!
    Thanks friends! 🤝 🤗 👐
    ⏱️ Timestamps:
    00:00 - Introduction
    01:07 - ABCs of Networking
    03:32 - Code Explanation & Walkthrough
    18:58 - Testing and debugging
    20:01 - Handling Client Connections
    21:23 - Outro
    🔗 Code Snippet:
    You can find the code used in this tutorial on GitHub: github.com/BekBrace/rust-tcp-...
    In this Rust networking tutorial, you will learn:
    1️⃣ How to import necessary modules from the Rust standard library for networking.
    2️⃣ Handling client connections using the handle_client function, which reads data from clients, processes it, and sends a response.
    3️⃣ Binding a TCP listener to address "127.0.0.1:8080" and listening for incoming connections.
    4️⃣ Using multithreading to handle multiple client connections concurrently.
    By the end of this video, you'll have a clear understanding of how to create a basic TCP server in Rust and how to handle client requests. Don't forget to like, subscribe, and hit the notification bell to stay updated with more Rust programming tutorials!
    🔗 GitHub Repository:
    github.com/BekBrace/rust-tcp-...
    🔗 Readme.md: github.com/BekBrace/rust-tcp-...
    🔗 Telegram Channel: t.me/bekbrace
    🔗 Instagram: / bek_brace
    🔗 Twitter: / bekbrace
    #RustProgramming #NetworkingInRust #TCP #RustTutorial #RustServer #RustNetworkingTutorial #LearnRust #programmingtutorial
    Join this channel to get access to perks:
    / @bekbrace
  • Věda a technologie

Komentáře • 53

  • @dantesbytes
    @dantesbytes Před 6 měsíci +15

    the fact that you explained everything line by line is priceless, I'm confindent that you wrote this yourself unlike 99% of the vidoes i come across on youtube seems like most of them don't have clue as to what they are teaching .

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

      Thanks so much for these words🙏. Indeed I've written it myself 🙂

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

    This was great, looking forward for the Tokio tutorial!

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

    Wow! very precise and clear.

  • @MPAXEL
    @MPAXEL Před 9 měsíci +2

    can't wait :)

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

    Thank you so much for depth knowledge

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

      I am so glad you enjoyed it

  • @orrenjenkins289
    @orrenjenkins289 Před 6 měsíci +3

    5:15 std::io::Read and std::io::Write are traits in the std::io module

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

    Excellently executed tutorial. Blow by blow, line by line. Subscribed.

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

      Thank you so much, Anthony 🙏🙂

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

    this video it's just perfect, I have no words to describe how amazing this is. Thanks a lot and the way you teach these things is just incredible.

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

      Thank you very very much for your kind words ❤️🙏 Your feedback is what pushes me forward to create more and more content | ••• Thank You !!!

  • @mohaniya15
    @mohaniya15 Před 9 měsíci +1

    Great video, I have just started with Rust videos on my channel, this really helped me.

    • @BekBrace
      @BekBrace  Před 9 měsíci

      Great my friend !
      Cool channel by the way, good luck in your journey 😀

  • @xsamuelx3603
    @xsamuelx3603 Před 9 měsíci +2

    Amazing video, my friend :)

    • @BekBrace
      @BekBrace  Před 9 měsíci

      Thank you very much 🙏🙏🙏

  • @AchroDev
    @AchroDev Před měsícem

    Love the video! Thanks for sharing your knowledge. I think it would have been better for the address to have been stored as a variable. This helps with a couple of things, but mostly saving you from re-writing the same string over and over.
    let address = "127.0.0.1:8080";
    let listener = TcpListener::bind(address).expect("Failed to bind to address: {address}");
    println!("Server listening on {}", address);

  • @volodyslove
    @volodyslove Před 3 měsíci +1

    That's so interesting 😁

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

      Thank you very much 👋☺️

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

    What happens, if the buffer is not large enough to read the whole message from the stream? I tried reading twice and concatenate the results into the string, but it didn’t seem to work…

  • @svetlana9699
    @svetlana9699 Před 9 měsíci +2

    🔥🔥🔥

    • @BekBrace
      @BekBrace  Před 9 měsíci

      Thank you 😊😊😊

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

    i am just three days into rust and i will still watch it

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

      Good luck and happy coding

  • @shivanshuraj7175
    @shivanshuraj7175 Před 13 hodinami

    How you can handle more than one connection without a loop encapsulating tcp incomming?....

  • @bEan-cf7mx
    @bEan-cf7mx Před 6 měsíci +4

    Can you make a video about Tokio please :)

    • @BekBrace
      @BekBrace  Před 5 měsíci +1

      Certainly )) Thanks for suggestion

  • @cahwardev9804
    @cahwardev9804 Před 9 měsíci +1

    Amazing video! What is the font and the color theme that used in the video?

    • @BekBrace
      @BekBrace  Před 9 měsíci

      Thank you.
      Theme: Bearded Theme Black & Ruby
      Font: Caskadiya Cove

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

    Hi. Isn't [0; 1024] mean 1024 ints? Or the type is being adjusted to u8 after it's use in read()?

    • @BekBrace
      @BekBrace  Před 5 měsíci +1

      So, when you see 0; 1024, think of it as a space reserved for 1024 elements. It's like having a box with 1024 slots, ready to store stuff. You know what I mean ? And what type of stuff goes in those slots depends on what you're doing with them.

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

      ​@@BekBrace​I found the answer: "Unsuffixed literal, their types depend on how they are used". So 0 literal retroactively binds to u8 a fine grained type upon buffer use in read().

  • @HumanoidTyphoon91
    @HumanoidTyphoon91 Před 2 měsíci +1

    Hate to be that guy, but what's your color theme? It looks amazing!

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

      No problem at all, my friend anything you want 🙂 the theme is VIM dark

  • @BRISKLYHIDDEN
    @BRISKLYHIDDEN Před 9 měsíci +1

    Slam Dunk 🏀

  • @abayaz61
    @abayaz61 Před 5 měsíci +1

    amazing content. please continue to rust series

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

      Hey! Thank you so much: More Rust to come!

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

    When is the next video coming In this series ?

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

      Next Month, there will be a new video in the series, thank you for your patience.

  • @harbi.delikanli
    @harbi.delikanli Před 9 měsíci

    Awesome video! May I ask the font name and color theme name? Thanks.

    • @BekBrace
      @BekBrace  Před 9 měsíci +1

      Thank you!
      Theme: Bearded Theme Black & Ruby
      Font: Caskadiya Cove

  • @xsamuelx3603
    @xsamuelx3603 Před 9 měsíci +1

    What's your terminal setup?

    • @BekBrace
      @BekBrace  Před 9 měsíci

      Yo .. check out my video: PowerShell Terminal Setup - all explained there/ peace

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

    What extentions do you use for rust?

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

    can you makea vid on how to make your device a priority and if possible involving the use of rustlang
    if it get uploaded can you please tag me or forward link as a reply

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

      Hi and thank you for this question.
      So, to prioritize your device using Rust, you can leverage Rust's thread module to set thread priorities through std::thread::Builder.
      Alternatively, for more granular control, use the libc crate to interact with the operating system API, allowing you to set process or thread priorities directly. Remember to test your application, monitor system behavior, and adjust priorities cautiously to avoid adverse effects on overall system performance and stability.
      Have I answered your question ?