python实现的简单的socket通信的客户端和服务器端,pythonsocket,服务端代码#!/usr/
python实现的简单的socket通信的客户端和服务器端,pythonsocket,服务端代码#!/usr/
服务端代码
#!/usr/bin/python # This is server.py fileimport socket # Import socket modules = socket.socket() # Create a socket objecthost = socket.gethostname() # Get local machine nameport = 12345 # Reserve a port for your service.s.bind((host, port)) # Bind to the ports.listen(5) # Now wait for client connection.while True: c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') c.close() # Close the connection
客户端代码
#!/usr/bin/python # This is client.py fileimport socket # Import socket modules = socket.socket() # Create a socket objecthost = socket.gethostname() # Get local machine nameport = 12345 # Reserve a port for your service.s.connect((host, port))print s.recv(1024)s.close # Close the socket when done
相关内容
- python 生成GUID(UUID),guiduuid,python的uuid模
- 正则分词,分词,def tokenize
- python随机生成指定长度的密码,python长度密码,python中的
- 速度生成多级目录,生成,directorys =
- Learn Python By Practice — dict,pythondict,def dictTest
- 导出linux用户权限,linux用户权限,要换linux服务器,由
- Python program to evaluate a polynomial with its derivatives,,## mo
- python访问系统环境变量,python访问环境变量,#----------
- Python 捕获web密码的程序,python捕获web密码,能够抓取P
- python回溯法实现数组全排列输出,python回溯,from sys im
评论关闭