Data Sheet

dScript
dScript User Manual v2.15
TCP/IP client
The tcp/ip client can initiate a communication to a tcp/ip server, we will use an ETH002 as an
example. To do this you need to define a client port like this:
clientport ETH002 "192.168.0.96" 17496 5000
The first parameter is the name of the client port that you will use in your program to refer to
this port. In this case an ETH002, so that's what we will name it. Next is its IP or DNS address
followed by the port number. The last parameter is the timeout in mS that we will wait for a
response. You may define any number of client ports but there is only one socket so only one
port can be connected at a time.
If the ETH002 is on the same network, that is all that is needed. However if the ETH002 were
at another location on the internet, we also need to set up a gateway address.
tcpip.gateway "192.168.0.1"
In this case the gateway is the address of our router since that is how we get out to the wider
internet.
If you have created a server name for your target device, such as yardlights.ddns.net then you
will also need to set up a dns address such as:
tcpip.dns1 "192.168.0.1"
tcpip.dns2 "8.8.8.8"
The first is normally your router address since this will point to the dns given by your isp. Here
we have used Google's public dns server for the second one.
This example uses an analogue input on the dS3484 to control an ETH002 relay which could be
anywhere on the internet.
tcpip.hostname "dS3484"
tcpip.ip "192.168.0.136"
tcpip.mask "255.255.255.0"
tcpip.port 17494
tcpip.dns1 "192.168.0.1"
tcpip.dns2 "8.8.8.8"
tcpip.gateway "192.168.0.1"
clientport ETH002 "yardlights.ddns.net" 17494 5000
analogport Adc1 1
digitalport LedBlue 32
digitalport LedGreen 33
digitalport LedRed 34
string clientOutBuf[10]
string clientInBuf[10]
var clientLength
var yardLightState
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
36