Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example of communication over Sockets

Example is placed in the folder: /Pm/Examples/Commun/Socket. This is an example of data communication between two PROMOTIC applications over Ethernet sockets. This communication type (via sockets) is now considered obsolete (but functional) in the PROMOTIC system and now is more useful to use XML communication. For the general description of the Socket communication see Data transfer in network over Sockets.
 
This example consists from 2 applications in the folders "Client" and "Server". Both application share two data objects "Data1" and "Data2" of the PmData type. There are 9 variables of the Integer type in "Data1" and 8 variables of the Double type in "Data2".
 
The "Server" application has created one Socked server group "MyData", which both objects "Data1" and "Data2" are connected to, on the "Sockets" page in the PmRoot object. The "Time" object increases the variable values in these objects every second.
 
The "Client" application has created one Client group "MyData", which both objects "Data1" and "Data2" are connected to, on the "Sockets" page in the PmRoot object. The Client group "MyData" has the network address of the server set to the TCPIP address "127.0.0.1", which is the shortcut for the local computer (the universal address of the computer where the application is running). If you want to test Client and Server on different computers connected to the network, the correct address of the server needs to be set here! In the client application it is possible to use the buttons for calling the ReadFromSocket and WriteToSocket methods.
 
Both applications can be viewed in the INFO system.

The Client application writes into the Debug information in the onEndOfTransfer event of the Data1 and Data2 objects. This event is called when the client transferred the data to/from the server - i.e. when Client calls ReadFromSocket or WriteToSocket.

The real values of the "Data1" and "Data2" objects can be also viewed in the INFO system.

© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice