<reponame>YouHao0809/Simple-HTTP-Server<filename>Reference Material/socket/client.py
# -*- encoding=utf-8 -*-


import socket


def client():
    # 1. 创建套接字
    s = socket.socket()
    # 2. 连接
    HOST = '127.0.0.1'
    PORT = 6666
    s.connect((HOST, PORT))
    # 3. 处理信息
    s.send(b'Hello World!')
    msg = s.recv(1024)
    print('From server: %s' % msg)


if __name__ == '__main__':
    client()
Material/socket/client.py
# -*- encoding=utf-8 -*-


import socket


def client():
    # 1. 创建套接字
    s = socket.socket()
    # 2. 连接
    HOST = '127.0.0.1'
    PORT = 6666
    s.connect((HOST, PORT))
    # 3. 处理信息
    s.send(b'Hello World!')
    msg = s.recv(1024)
    print('From server: %s' % msg)


if __name__ == '__main__':
    client()
# -*- encoding=utf-8 -*- # 1. 创建套接字 # 2. 连接 # 3. 处理信息