# coding:utf-8
import socket


class ClientSocket():

    def __init__(self):
        self.host = "10.100.11.125"
        self.port = 1078
        self.timeOut = 1
        self.client = None                                     # 客户端socket对象

    def setHost(self,data):
        self.host = data
    def setPort(self,data):
        self.port = data
    def setTimeOut(self,data):
        self.timeOut = data

    def connect(self):
        self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)  # 在客户端开启心跳
        self.client.connect((self.host, self.port))
        return  self.client

    def send(self,data):
        self.client.send(data)

    def close(self):
        self.client.shutdown(socket.SHUT_RDWR)
        self.client.close()