Socket Chatroom server – Creating chat application with sockets in Python

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.

Text-based tutorials and sample code:

Channel membership:
Support the content:


  1. Nabeegh Ahmed on

    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

  2. joshua donatante on

    What are these quads you got hung on a wall? Have you already talked about it? I can see some of them may be acrobatic ones! Will you share you point of view on UAVs?

  3. Aditya Singh on

    Ayyyye!! You’re back!! I owe you one bro… Your machine learning videos have made a huge boost in my resume!! Thought to inform you that you are making a huge difference!! Love from India !!

  4. Koens on

    I love you and your videos sentdex!!! Thanks for all of the incredible content, you’re the reason I started Python! <3

  5. Coded Pain on

    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

  6. Muhammad Usman on

    i m promoting your channel in udemy, when ever they say buy this series from us,its good its super cheap i paste your website links down in the comments 😀

  7. bloodgain on

    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.

  8. Kune Mohith on

    Hey sentdex, How do you learn/refer docs/sourcecode without an IDE like pycharm/intelliJ. Please tell me a way to refer documentation without internet. How do you do it?

  9. Krzych4ever on

    Can someone tell e if I add my test to that and do few minor changes can I post it into my github(with declaration that good portion is from sentdex)?

  10. Sébastien Lavoie on

    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 :).

  11. Raj Polinovsky on

    Thank you for the video.!
    Very interesting.
    But there are many such examples.
    And how can you make a chat using stur so that you can send messages for NAT?

  12. Randy Diaz on

    Someone is cheating on python! lol false, true is javascript/c++/java/Go. Also note that you can do

    if not message:

    instead of

    if message is False:

  13. Андрей локас on

    oooo wow you are just superb!!
    its my fav tutorials 🙂
    hope you do full course tutorials for python!
    thanks !!


Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons