Make your own free website on Tripod.com

Class CTCPIPServer

This class manages TCP/IP serial port interface. It's not possible to create instances of CTCPIPServer directly using VBA "New" function , that means , it's not a creatable class. You must use CreateTCPServer method from Modbus Server class.

 

Properties

GetLocalHostIP

syntax

TcpServer.GetLocalHostIP

HRESULT GetLocalHostIP([out,retval] BSTR* pbstrVal);

Remarks

This property is intended to find the IP address of the computer where was installed the Modbus Server. It was used two api functions: gethostname, gethostbyname to find IP Address. If the function fails a loopback address 127.0.0.1 is returned.

Data Type

String

ServerAddress

TcpServer.ServerAddress[=ServerAddress$]

HRESULT ServerAddress([out, retval] BSTR *pVal);
HRESULT ServerAddress([in] BSTR newVal);

Get/Set Server address. The TCP serial port interface do not automatically detect the ip address of the computer where the server was installed. You have to set this address before calling StartServer method. Generally you can set this property with the value returned by GetLocalHostIP but sometimes this not work.

Data Type

String

ServerPort

TcpServer.ServerPort[=ServerPort&]

HRESULT ServerPort([out, retval] long *pVal);
HRESULT ServerPort([in] long newVal);

Remarks:

Get/Set IP port. Open modbus protocol use port 502 as a default.

Data Type

Long

 

Methods

StartServer

TcpServer.StartServer

HRESULT StartServer([out,retval] VARIANT_BOOL* pbOk);

 

Return Value

True if function succeeds or False if fails.

Remarks

After setting ServerAddress and ServerPort , call this method to start TCP Serial port interface. If the return value is true any client can connect using TCP/IP network and send messages to the modbus device.

.

StopServer

TcpServer.StopServer

HRESULT StopServer([out,retval] VARIANT_BOOL* pbOk);

 

Return Value

True if function succeeds or False if fails.

Remarks

This method stop tcp server and disconnect any client that is using the server.

Modbus Automation Server , Home