//创建用于通讯的tcp信息实例 private static CommTCPEntity CreatCommTCPEntity(Model_Data.DeviceModel obj) { CommTCPEntity TCPE = new CommTCPEntity(); TCPE.IP = obj.Port.TCP.IP; TCPE.Port = obj.Port.TCP.Port; TCPE.WriteOverTime = obj.Port.WriteOverTime; TCPE.ReadOverTime = obj.Port.ReadOverTime; return(TCPE); }
private bool CreatSocket(CommTCPEntity TCPEntity) { this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, TCPEntity.WriteOverTime);//设置套接字发送超时 if (TCPEntity.ReadOverTime > 200) { this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, TCPEntity.ReadOverTime);//设置套接字接收超时 } else { this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 200); //设置套接字接收超时 } ip = new IPEndPoint(IPAddress.Parse(TCPEntity.IP), TCPEntity.Port); //IP和Port "192.168.0.225" return(true); }
public override bool SetParaMeter(CommTCPEntity SE) { return(socketWrapper.SetTCPEntity(SE)); }
public bool SetTCPEntity(CommTCPEntity TCPEntity) { TCPPara = TCPEntity; BeginConnectAsynCallback = new AsyncCallback(ConnectCallBack); return(CreatSocket(TCPPara)); }
public override bool SetParaMeter(CommTCPEntity SE) { return(true); }
public abstract bool SetParaMeter(CommTCPEntity SE);