TCP/IP Communications - Sample Projects PingPong_TCP_Server/Client.ptp

<< Click to Display Table of Contents >>

Navigation:  Examples and Tutorials (Scripting) >

TCP/IP Communications - Sample Projects PingPong_TCP_Server/Client.ptp

The project files PingPong_TCP_Server.ptp and PingPong_TCP_Client.ptp in the \ScriptSamples\Network folder demonstrate how to use Docklight Scripting as a TCP server or TCP client and exchange data.


The samples show how a server and a client can be run on the same computer using the LOCALHOST network name, which always refers to the computer Docklight is running on.


Getting started


Open the project PingPong_TCP_Server.ptp in Docklight Scripting

Press the play Start Communication button in the toolbar.

If you are using a Personal Firewall on your PC, it will probably notify you that Docklight Scripting wants to act as a server. Confirm and allow, if required.

Start a second instance of Docklight Scripting and open the PingPong_TCP_Client.ptp project

In this 'client' instance , press the Pt_Send_Button Send button for the "Ping" sequence.

If you are using a Personal Firewall on your PC, allow Docklight Scripting to connect to the Internet.


The 'client' Docklight now connects to the 'server' Docklight, and data is exchanged as if the two Docklight instances were connected by a serial null-modem cable.


The communication window on the client side now displays the following messages:


3/9/2009 17:29:24.192 [TX] - ----o Ping

3/9/2009 17:29:24.218 [RX] - o---- Pong "Pong" received

3/9/2009 17:29:24.221 [TX] - ----o Ping

3/9/2009 17:29:24.249 [RX] - o---- Pong "Pong" received

3/9/2009 17:29:24.254 [TX] - ----o Ping

3/9/2009 17:29:24.281 [RX] - o---- Pong "Pong" received

3/9/2009 17:29:24.283 [TX] - ----o Ping

3/9/2009 17:29:24.312 [RX] - o---- Pong "Pong" received



On the server side, you will see something like this:


3/9/2009 17:29:24.203 [RX] - ----o Ping "Ping" received

3/9/2009 17:29:24.206 [TX] - o---- Pong

3/9/2009 17:29:24.235 [RX] - ----o Ping "Ping" received

3/9/2009 17:29:24.238 [TX] - o---- Pong

3/9/2009 17:29:24.266 [RX] - ----o Ping "Ping" received

3/9/2009 17:29:24.268 [TX] - o---- Pong

3/9/2009 17:29:24.298 [RX] - ----o Ping "Ping" received

3/9/2009 17:29:24.301 [TX] - o---- Pong