FieldTalk Modbus Master Library for .NET
FieldTalk Modbus Master Library for .NET
Namespaces
FieldTalk.Modbus.Master
MbusUdpMasterProtocol Class
MbusUdpMasterProtocol Methods
adamSendReceiveAsciiCmd Method
setPort Method

# MbusUdpMasterProtocol setPort Method

Sets the TCP port number of the Modbus slave device.

Namespace: FieldTalk.Modbus.Master
Assembly: FieldTalk.Modbus.Master (in FieldTalk.Modbus.Master.dll) Version: 2.15.2-eval+3d8362b4bb861c05760d48b11d303e954bb8597c
Syntax
C#
VB
C++
Copy

    public override int setPort(
    	short portNo
    )

    Public Overrides Function setPort (
    	portNo As Short
    ) As Integer

    public:
    virtual int setPort(
    	short portNo
    ) override

#### Parameters

portNo
  Type: System
  Int16
  Port number to be used when opening the connection

#### Return Value

Type: Int32
BusProtocolErrors.FTALK_SUCCESS on success or error code. See BusProtocolErrors for possible error codes.
Remarks
Usually the port number remains unchanged and defaults to 502 for Modbus/TCP and 1100 for RTU over TCP. However if the port number has to be different this function must be called before opening the connection with openProtocol().

Note
A protocol must be closed in order to configure it.

See Also

#### Reference

MbusUdpMasterProtocol Class
FieldTalk.Modbus.Master Namespace
FieldTalk Modbus Master Library for .NET
Library version 2.15.2