public ViTcpClient() { UInt16 index = 0; UInt32 size = 0; _indexBytes = ViBitConverter.GetBytes(index); _lengthBytes = ViBitConverter.GetBytes(size); _receiveHead = new byte[RECEIVE_HEAD_SIZE]; _OS.Append(_indexBytes); _OS.Append(_lengthBytes); _receiver = new ViTcpCLientReceiver(RECEIVE_BYTES_SIZE); }
public void Update() { try { NetworkStream stream = _client.GetStream(); _lengthBytes = ViBitConverter.GetBytes(_OS.Length - SEND_HEAD_SIZE); _OS._SetValue(SEND_SIZE_OFFSET, _lengthBytes, _lengthBytes.Length); stream.Write(_OS.Cache, 0, _OS.Length); _OS.Reset(); _OS.Append(_indexBytes); _OS.Append(_lengthBytes); } catch (System.ObjectDisposedException ex) { SetConnectState(false); } catch (Exception ex) { SetConnectState(false); } }