How To Build A Custom TCP Server In Golang!?

  Рет қаралды 24,542

Anthony GG

Anthony GG

Жыл бұрын

► Join my Discord community for free education 👉 / discord
► Become a Patreon for more exclusive content 👉 / anthonygg_
► Buy my a coffee 👉 donate.stripe.com/aEU2a6ayH2u...
► Follow me on Twitter 👉 / anthdm
► Follow me on GitHub 👉 github.com/anthdm
In this Golang tutorial, I will teach you how to build a custom TCP server that can read from and write to incoming connections by just using the standard library.
#golang

Пікірлер: 67
@anthonygg_
@anthonygg_ Жыл бұрын
► 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
@user-dv5th8jk1i
@user-dv5th8jk1i Жыл бұрын
I got a lot of inspiration from looking at your code. thank you
@joewilliams8286
@joewilliams8286 Жыл бұрын
Thank you for creating the video man! Really enjoy your teaching style, +1 sub
@anthonygg_
@anthonygg_ Жыл бұрын
Thanks my man!
@anshkumargarhewal8582
@anshkumargarhewal8582 Жыл бұрын
Holy Shit...Just few days before your Subs. Were 2k now it's 3k .. Congratulations Anthony for This Badass videos🍻
@seanknowles9985
@seanknowles9985 4 ай бұрын
now its 40k
@madhank93
@madhank93 Жыл бұрын
I am so glad I found your channel.
@sagimor8646
@sagimor8646 5 ай бұрын
Great tutorial, thank you.
@tintin537
@tintin537 Жыл бұрын
Thank you for a nice tutorial
@moneyman2087
@moneyman2087 Жыл бұрын
man verrrryyyy helpfulll thanks
@gabrielmengassodefranca1615
@gabrielmengassodefranca1615 2 ай бұрын
hey man, i loved the video, thanks a lot !
@user-bh8xz4xy7o
@user-bh8xz4xy7o Жыл бұрын
thx so much for the video)))
@choleralul
@choleralul Жыл бұрын
Lekker hoor Tony!
@lautaroblasco
@lautaroblasco Жыл бұрын
Great video
@kamalshkeir
@kamalshkeir Жыл бұрын
awesome stuff !
@anthonygg_
@anthonygg_ Жыл бұрын
Thanks my man!
@regionkaz
@regionkaz Жыл бұрын
Thanks a lot! I like your style. It would be interesting to watch about vim shortkeys that you use.
@anthonygg_
@anthonygg_ Жыл бұрын
Will make one !
@elakstein
@elakstein Жыл бұрын
@@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 :)
@user-nx2od3pt1b
@user-nx2od3pt1b 2 ай бұрын
you are gowsome !!
@eamarc
@eamarc Жыл бұрын
Please make video about your programming environment setup.
@CoffeeCoderDev
@CoffeeCoderDev 6 ай бұрын
tks!!
@peter.teslenko
@peter.teslenko Жыл бұрын
Ctrl-L - clear terminal
@anthonygg_
@anthonygg_ Жыл бұрын
Clear
@hienluongvi3533
@hienluongvi3533 4 ай бұрын
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,
@QckSGaming
@QckSGaming Жыл бұрын
Close telnet with ^] or CTRL+]
@justmeandmy
@justmeandmy 3 ай бұрын
"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"
@exiit423
@exiit423 Жыл бұрын
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_ Жыл бұрын
Yes. That a bug. Good catch.
@KennethFeur
@KennethFeur 5 ай бұрын
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 3 ай бұрын
Another option is to bring the buf declaration into the for loop so one exists per loop iteration.
@variel3200
@variel3200 7 ай бұрын
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?
@anthonygg_
@anthonygg_ 7 ай бұрын
Correcr
@atticus_foust
@atticus_foust Жыл бұрын
Hell yeah watched an ad for you haha
@anthonygg_
@anthonygg_ Жыл бұрын
I hope it was a good one 🎉
@pouris
@pouris 9 ай бұрын
I didn't know GSP had a youtube channel about programming xD
@wMwPlay
@wMwPlay Жыл бұрын
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_ Жыл бұрын
I would use json api for that.
@lokthar6314
@lokthar6314 Жыл бұрын
love your content again, when will you bring some Rust stuff? Also when would you pick Rust over Go and vice versa?
@anthonygg_
@anthonygg_ Жыл бұрын
Will do some Rust this week!
@lokthar6314
@lokthar6314 Жыл бұрын
@@anthonygg_ cant wait!
@Kunal-k-u-m-a-r
@Kunal-k-u-m-a-r 20 күн бұрын
how about creating alternative open source for openssh
@agenticmark
@agenticmark Жыл бұрын
I got my channel back Anthony! Let’s do one where you teach me go and I teach you functional js
@anthonygg_
@anthonygg_ Жыл бұрын
What happened with that channel?
@agenticmark
@agenticmark Жыл бұрын
@@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_ Жыл бұрын
@@agenticmark what about all your subs?
@agenticmark
@agenticmark Жыл бұрын
@@anthonygg_ gone for now, we will see what happens
@anthonygg_
@anthonygg_ Жыл бұрын
@@agenticmark thats to bad. Keep going they will come back
@najamawan
@najamawan 8 ай бұрын
github code repo?
@VijayChintapandu
@VijayChintapandu 21 күн бұрын
Where is git repo for this video.
@dejanduh2645
@dejanduh2645 8 күн бұрын
You didn't show how to use the quitch
@veereshpatel.46
@veereshpatel.46 Жыл бұрын
Please add timestamps
@none_the_less
@none_the_less Жыл бұрын
The content is already free, now you want it with stamps? It’s a 19 min video dude.
@elakstein
@elakstein Жыл бұрын
Consider paying him some money 💰.
@codyf1
@codyf1 Жыл бұрын
tpc or tcp? 1:28
@anthonygg_
@anthonygg_ Жыл бұрын
Cpt
@baxiry.
@baxiry. Жыл бұрын
7:24
@MGtvMusic
@MGtvMusic Жыл бұрын
@@anthonygg_ HAHAHAHHA
@keyhanalizadeh1991
@keyhanalizadeh1991 Жыл бұрын
@@anthonygg_ pct
@Scratchmex
@Scratchmex Жыл бұрын
why do you keep moving your pointer when you are writing? it is very distracting haha. Apart from that good video!
@anthonygg_
@anthonygg_ Жыл бұрын
Adhd
@Sammysapphira
@Sammysapphira 18 күн бұрын
Aggravating variable names Ho wld it feel to hve wrds typ lik this
@keyhanalizadeh1991
@keyhanalizadeh1991 Жыл бұрын
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 5 ай бұрын
how did you solve this problem?
@everest9289
@everest9289 5 ай бұрын
Same here
@SuperFishers
@SuperFishers 2 ай бұрын
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
Important Tips On How To Write Idiomatic Code In Golang
21:52
Anthony GG
Рет қаралды 21 М.
How To Build A Chat And Data Feed With WebSockets In Golang?
20:45
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 12 МЛН
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 34 МЛН
Пробую самое сладкое вещество во Вселенной
00:41
🌐 Network Programming in Rust - Building a TCP Server
21:55
James Beilby (Banking Industry): An Algo Execution System in Rust
10:32
Understanding Recruitment
Рет қаралды 1,5 М.
How To Structure Your Golang (API) Projects!?
20:28
Anthony GG
Рет қаралды 44 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 96 М.
I'm Coming Around To Go...
21:33
Theo - t3․gg
Рет қаралды 102 М.
Tower Defense: How TCP Packets Work
8:52
TheVimeagen
Рет қаралды 34 М.
This Is The BEST Way To Structure Your GO Projects
11:08
Melkey
Рет қаралды 64 М.
Why I Use Golang In 2024
9:21
ThePrimeTime
Рет қаралды 256 М.
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 12 МЛН