1 Star 0 Fork 46

张鹏/qytang_Python

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
2016.1.14.1 改良版本echo-client 639 Bytes
Copy Edit Raw Blame History
import sys
import socket
def echoc(srvHost, srvPort, msg):
sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockobj.connect((srvHost, srvPort))
sockobj.send(msg)
data = sockobj.recv(1024)
print('Client received:', data.decode())
#sockobj.close()
if __name__ == '__main__':
message = 'Hello network world'
if len(sys.argv) > 1:
serverHost = sys.argv[1]
#print(serverHost)
if len(sys.argv) > 2:
serverPort = int(sys.argv[2])
#print(serverPort)
if len(sys.argv) > 3:
message = (x.encode() for x in sys.argv[3:])
#print(message)
echoc(serverHost, serverPort, message)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/networker-python/qytang_Python.git
git@gitee.com:networker-python/qytang_Python.git
networker-python
qytang_Python
qytang_Python
master

Search