From f16e0ab5dfea279d39878a824ec48d815de50e97 Mon Sep 17 00:00:00 2001 From: Hongliukai <773722914@qq.com> Date: Wed, 13 Mar 2024 13:35:18 +0800 Subject: [PATCH] feature : remoteTSAP connectType (driver)can override by TCPClientWithConnectType() --- tcpclient.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tcpclient.go b/tcpclient.go index a8a5782..9fba882 100644 --- a/tcpclient.go +++ b/tcpclient.go @@ -48,12 +48,27 @@ func NewTCPClientHandler(address string, rack int, slot int) *TCPClientHandler { h.setConnectionParameters(address, 0x0100, remoteTSAP) return h } - +// NewTCPClientHandlerWithConnectType allocates a new TCPClientHandler with connection type. +func NewTCPClientHandlerWithConnectType(address string, rack int, slot int, connectType int) *TCPClientHandler { + h := &TCPClientHandler{} + h.Address = address + h.Timeout = tcpTimeout + h.IdleTimeout = tcpIdleTimeout + h.ConnectionType = connectType + remoteTSAP := uint16(h.ConnectionType)<<8 + (uint16(rack) * 0x20) + uint16(slot) + h.setConnectionParameters(address, 0x0100, remoteTSAP) + return h +} //TCPClient creator for a TCP client with address, rack and slot, implement from interface client func TCPClient(address string, rack int, slot int) Client { handler := NewTCPClientHandler(address, rack, slot) return NewClient(handler) } +//TCPClientWithConnectType creator for a TCP client with address, rack, slot and connect type, implement from interface client +func TCPClientWithConnectType(address string, rack int, slot int, connectType int) Client { + handler := NewTCPClientHandlerWithConnectType(address, rack, slot, connectType) + return NewClient(handler) +} // tcpPackager implements Packager interface. type tcpPackager struct {