Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Created June 11, 2019 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinglunliao/5b33d42cbaed95bd60001d1a6673764b to your computer and use it in GitHub Desktop.
Save pinglunliao/5b33d42cbaed95bd60001d1a6673764b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import socket
s = socket.socket()
host = socket.gethostname() # 取得目前機器名稱
print(host)
port = 12345 # 程式的 port number
s.connect((host, port)) # 連線到 server
recvMsg = s.recv(1024) # 接收 server 傳來的訊息
print( recvMsg.decode('utf-8') )
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment