Socket Chatroom server - Creating chat application with sockets in Python

preview_player
Показать описание
We've made it through the basics of working with sockets, and now we're ready to try to actually build something with them, so, in this sockets with Python tutorial, we're going to build a console-based chat app.

Рекомендации по теме
Комментарии
Автор

I LOVE YOU! I am literally trying to figure out how to make a chatroom server, which only receives messages from clients and delivers them to other clients connected, for a whole week now

stratisdermanoutsos
Автор

i really fucking love your tutorials, you have this classy-funny engineer vibe, it just is fun to watch your stuff man, keep goin

Jonasgeorg
Автор

When the parser has an error, there is a little arrow ^ which will point out the error. In your error, you can see it is pointing directly to the ". In this case it would have saved you a few minutes, in the future it might have saved you a few hours :)

shiuido
Автор

This taught me a lot about how traffic is handled by servers, thanks for the great video!

danm
Автор

22:09 The code runs!!! :) Superb tutorial! As always, it's fun to watch. By the way, if I may, I would suggest splitting long lines so that you don't have to zoom out. As long as parentheses are used, you can pretty much cut the string wherever you want for any kind of statement, like:
print(f'Very long {text_variable} going '
'here and continuing there. '
'Actually with proper indentation of course.')


Thank you. Your kitchen must be filled with quite a huge collection of mugs, that's also entertaining :).

slavoie
Автор

And as always:

"... I forgot what Python version I'm using."

whammynator
Автор

i made an complete webchat app using this tutorial as a base, thank you!

Aragubas
Автор

7:30 Should be "return False".
Edit: Glad you fixed it at 9:55

MacintoshFanTechnology
Автор

Hey Sentdex, I've following your channel for a long time now and I've grown accustomed to your style of teaching. I just have a little suggestion to you that I think would make your videos more awesome. Before writing any line of code that might not be obvious for the viewers to imagine and see why it's used, please explain a little bit about it or what the end result would be, sometimes it's hard for us to figure out and try to formulate as we what the end result might be. Like at 3:10 you explained why we used setsockopt () but at 14:20 and 17:30 it started to get cluttered up very fast and I got lost.
Just a little input from my side. Thank you for your tutorials.

vaibhavsingh
Автор

In case you don't like the weird way to convert with f-strings/strip to manage bytes, here is another version:
bytes_header = int.to_bytes(len(bytes_message), HEADER_LENTH, "big")
int_header = int.from_bytes(bytes_header, "big")

And to convert string to bytes:
bytes_data = bytes(data, "utf-8")
utf8_data = bytes_data.decode("utf-8")

Bvic
Автор

I remember your old days bro, that small room and making GTA V AI videos, you have come a long way and it was phenomenal to be a part of this

nabeeghahmed
Автор

First I disliked because I thought you were not being clear enough..
but then I also realized the reason behind that being is that you are on another level compared to myself..


Though I will probably connect the dots and have a well written code.. so *Thumbs up* xD
Please do not hate me - I liked every other video I watched from you hahaha, great tutorials!


*EDIT: Oh boy was I wrong - I just went to the 1st link you provided in the description :'D*

dnetne
Автор

my friends: how do you make that??
"me last 2 hours because stoping video"
idk how but it works

josephstalin
Автор

Good start to this tutorial; I'm looking forward to seeing the next part.


Minor quibble with your receive_message function: since your "good" return value is a dict, it's really better if you return an empty dict on failure, or at least None, rather than False. Multivariate return types are problematic because they are less predictable to users and require extra -- and usually non-Pythonic -- handling code everywhere the function is called. Pandas does this, and it drives me nuts, but there's no other package that approaches what it does. None gets a pass because it's a non-value, and "may return None" is considered a standard function contract by the Python community -- which, of course, you'd say explicitly in your docstring.


Since both None and empty dict are "falsey", you can still check with "if [not] message:", though some "ask forgiveness, not permission" diehards will say you should really just _try_ to access message and handle the empty/None case in the except clause. Note that the latter method is _only_ advisable in Python, though, and using exceptions for flow control is frowned upon in most programming languages.

bloodgain
Автор

Great series! Have been following you for a while now and you keep posting good content!

moniquemarinslp
Автор

quick question, how do we make it so that when a user sends a message, everyone's chat screen is automatically updated with the most recent messages? Currently, it only updates if the user sends a message or clicks enter.

Shingorani
Автор

just look. its just me frantically looking for part 2 since it was never mentioned in the damn desc

kindersmith
Автор

14:50 "It'll be fine." story of all coding ever

jaxhorn-lquv
Автор

hey sentdex I love your tutorials You are awesome

VISHALSHARMA-qbue
Автор

nice! Thanks for the tutorial. As a novice, this tutorial is easy to understand.

blatogh