Skip to content

Commit

Permalink
Merge pull request #67 from Hongliukai/featuer-connect_with_connectType
Browse files Browse the repository at this point in the history
feature : remoteTSAP connectType (driver)can override by TCPClientWit…
  • Loading branch information
robinson authored Mar 15, 2024
2 parents fb5a72f + f16e0ab commit 1f14519
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tcpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1f14519

Please sign in to comment.