How To Build A Custom TCP Server In Golang!?

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น •

  • @anthonygg_
    @anthonygg_  2 ปีที่แล้ว +1

    ► Join my Discord community for free education 👉 discord.com/invite/bDy8t4b3Rz
    ► Become a Patreon for exclusive tutorials👉 www.patreon.com/anthonygg_
    ► Buy me a coffee 👉 donate.stripe.com/aEU2a6ayH2uCa3u4gg
    Thanks for watching

  • @madhank93
    @madhank93 2 ปีที่แล้ว +8

    I am so glad I found your channel.

  • @upgames1313
    @upgames1313 7 วันที่ผ่านมา

    Thanks for the video! This is just what I was looking for

  • @joewilliams8286
    @joewilliams8286 ปีที่แล้ว +6

    Thank you for creating the video man! Really enjoy your teaching style, +1 sub

  • @anshkumargarhewal8582
    @anshkumargarhewal8582 2 ปีที่แล้ว +3

    Holy Shit...Just few days before your Subs. Were 2k now it's 3k .. Congratulations Anthony for This Badass videos🍻

  • @야니스-l6b
    @야니스-l6b ปีที่แล้ว +5

    I got a lot of inspiration from looking at your code. thank you

  • @oii0712
    @oii0712 3 หลายเดือนก่อน

    Exactly what i was looking for

  • @exiit423
    @exiit423 ปีที่แล้ว +5

    Good example, but there is a major bug in the code: The "buf" slice is being reused, but the buf is not copied before it's sent to the channel (msgch). buf[n:] only creates a new slice pointing to the same address but with a different length.
    TCP already comes with backpressure so I'm not sure how much use there is for the extra channel. But if you want to use a channel, allocate a new slice (buf) each iteration.

    • @anthonygg_
      @anthonygg_  ปีที่แล้ว +2

      Yes. That a bug. Good catch.

    • @KennethFeur
      @KennethFeur 11 หลายเดือนก่อน

      Thank you for your comment! I'm new to golang and was wondering why the channel data is being overwritten if I allocate small buffer and send a message longer than the buffer size. All makes sense now.

    • @justmeandmy
      @justmeandmy 10 หลายเดือนก่อน

      Another option is to bring the buf declaration into the for loop so one exists per loop iteration.

    • @marcellmunnich1094
      @marcellmunnich1094 หลายเดือนก่อน

      Shouldn't it be fine in this case? conn.Read() is blocking and so is the channel send operation. Since a separate go routine is spun up for every client, there shouldn't be a way of overwriting each other's data.
      A copy is created when it gets sent to the channel, and there's no way for other client's or new messages of the same client to interfere with the value of the buf until it gets to that point (basically buf will stay the same value until the copy into the channel has been made, it can then read again from the connection).
      Correct me if I'm wrong though, still new to go...

  • @sagimor8646
    @sagimor8646 11 หลายเดือนก่อน

    Great tutorial, thank you.

  • @hienluongvi3533
    @hienluongvi3533 10 หลายเดือนก่อน

    i have a question
    at 07:15
    as i understand, the for loop inside readLoop function will keep reading data from connection by using conn.Read
    can we put read message process to goroutine?
    what will be the different between using goroutine and not using goroutine at this situation?
    thanks,

  • @regionkaz
    @regionkaz 2 ปีที่แล้ว +1

    Thanks a lot! I like your style.
    It would be interesting to watch about vim shortkeys that you use.

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว

      Will make one !

    • @elakstein
      @elakstein 2 ปีที่แล้ว

      @@anthonygg_ I will also love if you could make a vim setup tutorial and all vim plugins you are using.
      In my company I do ssh to a server and I don't have sudo access and internet is blocked to that server, I can SFTP files from local device to that server if you could help in setting up vim with these constraint then I will be thankful. Maybe I asked too much :)

  • @gabrielmengassodefranca1615
    @gabrielmengassodefranca1615 8 หลายเดือนก่อน

    hey man, i loved the video, thanks a lot !

  • @tintin537
    @tintin537 2 ปีที่แล้ว +1

    Thank you for a nice tutorial

  • @moneyman2087
    @moneyman2087 2 ปีที่แล้ว

    man verrrryyyy helpfulll thanks

  • @Kisme-e9f
    @Kisme-e9f ปีที่แล้ว +3

    7:44 I'm getting a deadlock error!
    goroutine 1 [chan receive]:
    main.(*Server).start(0xc0000c9f48)
    D:/projects/tcp/main.go:32 +0xc5
    main.main()
    D:/projects/tcp/main.go:67 +0x5c
    exit status 2

    • @tarjaqt
      @tarjaqt ปีที่แล้ว +1

      how did you solve this problem?

    • @everestp8
      @everestp8 11 หลายเดือนก่อน

      Same here

    • @SuperFishers
      @SuperFishers 8 หลายเดือนก่อน

      You probably fixed this by now (or moved on to something else!) but this error might be from not calling "go s.acceptLoop()" in Start().
      Anthony doesn't get this error but he fixes this a little bit later in the video

  • @Programscape
    @Programscape ปีที่แล้ว +1

    thx so much for the video)))

  • @kamalshkeir
    @kamalshkeir 2 ปีที่แล้ว +1

    awesome stuff !

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว +1

      Thanks my man!

  • @choleralul
    @choleralul ปีที่แล้ว +1

    Lekker hoor Tony!

  • @lautaroblasco
    @lautaroblasco ปีที่แล้ว

    Great video

  • @eamarc
    @eamarc 2 ปีที่แล้ว +2

    Please make video about your programming environment setup.

  • @justmeandmy
    @justmeandmy 10 หลายเดือนก่อน +2

    "I dont know how to close telnet"
    It literally hints you how each you make a connection.
    "Escape character is '^]'."
    that is "control-]"
    Then you will get a telnet> prompt ... type "quit"

  • @variel3200
    @variel3200 ปีที่แล้ว +2

    Hi, I want to thank you by providing this tutorial, It helps me a lot. May I confirm something? Is the reason you put goroutine of readloop() inside acceptloop() is for handling multiple message in the same connection?
    So lets say you send a request to the server, but the server still can receive another request while processing the first request isn't it?

  • @lokthar6314
    @lokthar6314 2 ปีที่แล้ว +1

    love your content again, when will you bring some Rust stuff? Also when would you pick Rust over Go and vice versa?

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว +1

      Will do some Rust this week!

    • @lokthar6314
      @lokthar6314 2 ปีที่แล้ว

      @@anthonygg_ cant wait!

  • @QckSGaming
    @QckSGaming ปีที่แล้ว +2

    Close telnet with ^] or CTRL+]

  • @atticus_foust
    @atticus_foust 2 ปีที่แล้ว +1

    Hell yeah watched an ad for you haha

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว

      I hope it was a good one 🎉

  • @pouris
    @pouris ปีที่แล้ว

    I didn't know GSP had a youtube channel about programming xD

  • @RavikantKumar-h9y
    @RavikantKumar-h9y 8 หลายเดือนก่อน

    you are gowsome !!

  • @shomikhan1333
    @shomikhan1333 5 หลายเดือนก่อน

    Thanks a lot

  • @Kunal-k-u-m-a-r
    @Kunal-k-u-m-a-r 6 หลายเดือนก่อน

    how about creating alternative open source for openssh

  • @peter.teslenko
    @peter.teslenko 2 ปีที่แล้ว +7

    Ctrl-L - clear terminal

  • @wMwPlay
    @wMwPlay 2 ปีที่แล้ว +1

    Quick off-topic question. Is it a good to idea to use TCP for my backend app so I can build native desktop GUI and use it? GUI connects to my go backend app via localhost tcp. Anyway, great video, will use it for my pet-project as an example. Thanks!

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว +1

      I would use json api for that.

  • @deepanshusharma1619
    @deepanshusharma1619 5 หลายเดือนก่อน

    Unable to accept your discord community invite

  • @agenticmark
    @agenticmark 2 ปีที่แล้ว +1

    I got my channel back Anthony! Let’s do one where you teach me go and I teach you functional js

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว

      What happened with that channel?

    • @agenticmark
      @agenticmark 2 ปีที่แล้ว

      @@anthonygg_ it got hacked, then deleted. youtube is slowly bringing it back to life
      i havent had access in a few weeks now.

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว

      @@agenticmark what about all your subs?

    • @agenticmark
      @agenticmark 2 ปีที่แล้ว +1

      @@anthonygg_ gone for now, we will see what happens

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว

      @@agenticmark thats to bad. Keep going they will come back

  • @CoffeeCoderDev
    @CoffeeCoderDev ปีที่แล้ว

    tks!!

  • @VijayChintapandu
    @VijayChintapandu 6 หลายเดือนก่อน

    Where is git repo for this video.

  • @najamawan
    @najamawan ปีที่แล้ว

    github code repo?

  • @dejanduh2645
    @dejanduh2645 6 หลายเดือนก่อน

    You didn't show how to use the quitch

  • @veereshpatel.46
    @veereshpatel.46 2 ปีที่แล้ว +2

    Please add timestamps

    • @bjojosimpson
      @bjojosimpson 2 ปีที่แล้ว +2

      The content is already free, now you want it with stamps?
      It’s a 19 min video dude.

    • @elakstein
      @elakstein 2 ปีที่แล้ว +3

      Consider paying him some money 💰.

    • @daffarandika3148
      @daffarandika3148 หลายเดือนก่อน

      guys chill, expecting a youtuber to annotate his own video with timestamps is not unreasonable. Also timestamp is useful when rewatching. I don't want to scroll on the timeline blindly, guessing which part discusses XYZ. Timestamps make the video more accessible and user-friendly, saving viewers time.

  • @Codeman4043
    @Codeman4043 2 ปีที่แล้ว +1

    tpc or tcp? 1:28

    • @anthonygg_
      @anthonygg_  2 ปีที่แล้ว +9

      Cpt

    • @baxiry.
      @baxiry. 2 ปีที่แล้ว +1

      7:24

    • @MGtvMusic
      @MGtvMusic ปีที่แล้ว

      @@anthonygg_ HAHAHAHHA

    • @Kisme-e9f
      @Kisme-e9f ปีที่แล้ว

      @@anthonygg_ pct

  • @Scratchmex
    @Scratchmex 2 ปีที่แล้ว +1

    why do you keep moving your pointer when you are writing? it is very distracting haha. Apart from that good video!

  • @Sammysapphira
    @Sammysapphira 6 หลายเดือนก่อน

    Aggravating variable names
    Ho wld it feel to hve wrds typ lik this