Em làm theo hướng dẫn bên Tutorialpoint, tạo một server như sau
#!/usr/bin/python3 # This is server.py file
import socket
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
# get local machine name
host = socket.gethostname()
port = 9999
# bind to the port
serversocket.bind((host, port))
# queue up to 5 requests
serversocket.listen(5)
while True:
# establish a connection
clientsocket,addr = serversocket.accept()
print("Got a connection from %s" % str(addr))
msg='Thank you for connecting'+ "\r\n"
clientsocket.send(msg.encode('ascii'))
clientsocket.close()
Nhưng mà khi cho chạy thì xuất hiện lỗi này
đọc code không thấy chỗ nào có yêu cầu mở file “#” cả. Giúp em fixx với ạ :D.
Link bài viết của tutorialspoint: https://www.tutorialspoint.com/python3/python_networking.htm