update 添加通讯等基本框架
This commit is contained in:
24
COM/COM_TCP.py
Normal file
24
COM/COM_TCP.py
Normal file
@ -0,0 +1,24 @@
|
||||
import json
|
||||
import socket
|
||||
|
||||
class TCPClient:
|
||||
def __init__(self,ip,port):
|
||||
self.IPAddress = ip
|
||||
self.port = port
|
||||
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
|
||||
def CreatConnect(self):
|
||||
self.client_socket.connect(self.IPAddress, self.port)
|
||||
|
||||
|
||||
def is_Connect(self):
|
||||
try:
|
||||
self.client_socket.send(b'', socket.MSG_DONTWAIT)
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user