简体   繁体   English

如何在python3中编写一个简单的服务器套接字和一个简单的客户端套接字?

[英]How to write a simple server socket, and simple client socket in python3?

The title basically says it all. 标题基本上说明了一切。 I want the absolute, most barebones, simplest implementation of a server socket, and a client socket. 我想要服务器套接字和客户端套接字的绝对,最准,最简单的实现。 Im sure there are questions similar to this, but I have not found anything that works for me. 我肯定有与此类似的问题,但是我还没有发现任何对我有用的东西。 If possible, please have the server socket send the message "hi" to the client socket which receives this and prints it out. 如果可能的话,请让服务器套接字向客户端套接字发送消息“ hi”,客户端套接字接收该消息并打印出来。 Vice-versa would also be nice just so I can see a client sending to a server and how it works. 反之亦然也很好,因为我可以看到客户端发送到服务器及其工作方式。 Thanks! 谢谢!

除了Python文档外, tutorialspoint也是开始学习的好地方

该文档几乎满足您的要求: https : //docs.python.org/3/library/socket.html#example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM