赞
踩
-
- import os,sys,time
- import socket
- import errno
- from time import sleep
-
- def main():
- client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- client.setblocking(0)
- connect = False
- while True:
- try:
- if connect == False:
- client.connect(("192.168.0.101",60000))
- connect = True
- client.send(bytes('hello', 'UTF-8'))
- msg = client.recv(4096)
- except socket.error as e:
- err = e.args[0]
- if err == errno.EAGAIN or err == errno.EWOULDBLOCK:
- print('No data available')
- elif err == errno.EINPROGRESS:
- print('Connecting')
- else:
- # a "real" error occurred
- print(e
- )
- connect = False
- client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- client.setblocking(0)
- else:
- # got a message, do something :)
- print("Receive '%s'" % msg)
- time.sleep(0.2)
-
- if __name__ == "__main__" :
- main()
-
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。