百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

python-client-server

> 编程语言
开源

一个使用 Python 的套接字和线程库的 TCP 客户端/服务器网络的基本示例。

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个使用 Python 的套接字和线程库的 TCP 客户端/服务器网络的基本示例。

Client-Server Network

A basic example of a TCP client/server network using Python's socket and threading library. The server uses instances of a client object and individual threads to listen to incoming data from each client while listening for new connections.

Running

  • Download the server.py and client.py python files for Python 3.
  • Run server.py. You will be prompted for a host and port for the server. If you are going to run the client on the same computer or local network as the server, use localhost as the host name. If you are going to run the client on a different network, use the computer's local IP address (the IP address that resembles one of these). The port can be any 16 bit number (lower than 65535), but must be forwarded on your router if the client will be on a different network.
  • Run client.py. If the server is running on the same computer, use localhost as the host. If the server is running on a different computer, but the same local network, use the local IP address of the computer that the server is running on. If the server is running on a different network, use the external IP address of the network that the server is running under (google what is my ip).

Usage

The client should successfully connect to the server. Each time the server accepts a new connection, it will print the connection information to the server console. When the server receives a message from any of the clients, it will print the message to the server console and bounce the messsage to all other clients (not the client that sent it).

On the client, just type in a message and hit enter to send it to the server. Due to the way the console works, if a message is sent to you while you are typing a message yourself, it will interrupt your typing.

Issues· 4 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言