[Python] [Source Code] SocketIO makes an online chat room software-server source code

【background】

The company wants to have a chat software that can be used on the LAN to facilitate business communication among department colleagues.
Today I will mainly talk about the source code of the server side, and I will continue writing the client source code tomorrow.

[Ideas]

Since I have configured a Python environment for all the computers in the company, I want to simply implement one using python and SocketIO.
The server side is directly python, running on the server and does not require a GUI interface.
The client GUI uses tkinter, and there is no need to package it. Just run the py file directly on the terminal.
The general design is that the client is fully connected to the server. The server receives any client message and broadcasts it to all connected clients. The effect displayed on the client interface is a chat room.

【Required Package】

The main packages that need to be installed include:
TCP connection communication is required, so installing socket
requires multi-threading, so installing threading
client requires GUI interface, so tkinter must be installed.

[Key code of server side]

Since it is a LAN deployment, the HOST name is '127.0.0.1' representing the local machine. Choose an unoccupied PORT. I chose 9090.
If you want to deploy to the external network, just make the corresponding public network settings.

HOST = '127.0.0.1'
PORT = 9090

Create a Server instance, Cli

Guess you like

Origin blog.csdn.net/weixin_41697242/article/details/132775582