Skip to content

Delphi and C++Builder DataSnap Server tip - displaying the TCP/IP and Port

I’ve always wanted to display the TCP/IP address and Port number on the caption of my Delphi and C++ DataSnap servers.  Here is the code that accomplishes this for my DataSnap Server form’s OnCreate event.

For Delphi:

1) Add the IdStack unit to the uses clause in your form’s implementation section

2) Add the following code to your OnCreate event handler:


    Form1.Caption := 'Embarcadero DSServer Application. IP Addr: '
    + GStack.LocalAddress
    + ' Port: '
    + IntToStr(DSTCPServerTransport1.Port);

For C++Builder:

1) Add #include <IdStack.hpp> near the top of the form’s source code

2) Add the following code to your OnCreate event handler:


    Form1->Caption = "Embarcadero DSServer Application. IP Addr: "
    + GStack->LocalAddress
    + " Port: "
    + IntToStr(DSTCPServerTransport1->Port);

For which form should you add the uses/#include and code?  On the form or data module that contains the DataSnap server, server class and transport components.

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 4 access attempts in the last 7 days.

Close