Python full stack __ Server and multi-client communication, UDP protocol, Pycharm printing with color output, time synchronization mechanism

Source: Internet
Author: User

1. Server and multi-client communication

1 ImportSocket2 #to create a socket for a TCP socket3SK =Socket.socket ()4 #Bind5Sk.bind (('127.0.0.1', 8080))6 #Monitor7Sk.listen (5)8 #Waiting for connection9  while1:Tenconn, addr =sk.accept () One      while1: Amsg_s = input ('>>>') -Conn.send (Msg_s.encode ('Utf-8')) -         ifmsg_s = ='Q': the              Break -Msg_r = Conn.recv (1024x768). Decode ('Utf-8') -         ifMsg_r = ='Q': -              Break +         Print(Msg_r) - conn.close () +  ASk.close ()
tcp_ server-side

1 ImportSocket2 3SK =Socket.socket ()4 5Sk.connect (('127.0.0.1', 8080))6 7 8  while1:9Msg_r = Sk.recv (1024x768). Decode ('Utf-8')Ten     ifMsg_r = ='Q': One          Break A     Print(Msg_r) -msg_s = input ('>>>') -Sk.send (Msg_s.encode ('Utf-8')) the     ifmsg_s = ='Q': -          Break -  -Sk.close ()
TCP_ Client

2. UDP protocol

3, Pycharm printing with color output

4, the mechanism of time synchronization

Python full stack __ Server and multi-client communication, UDP protocol, Pycharm printing with color output, time synchronization mechanism

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.