MexBIOS Development Studio: Client Server technology
CLIENT SERVER TECHNOLOGY
In MexBIOS™ Development Studio an interprocessor communication feature with client-server architecture is built in.
A server outputs necessary data on client’s request.
The client initiates connection to the server and sends a request for outputting the necessary data.
While starting the MexBIOS™ Development Studio the server is initiated automatically. The server while initiating reserves the TCP/IP protocol port. Default port number is 654321. Several applications can not exploit the same port at the same time, therefore, if while starting the MexBIOS™ Development Studio the port is already occupied by another running copy of MexBIOS™ Development Studio or by any other software exploiting the TCP/IP protocol, an error message is output.
The port number can be changed in Server inlay under Server Upper panel.


- Add to the Workspace an OUT block.
- Assign to the block a visual control Server.
- Set the visual control parameters.


- Add an IN block to the Workspace.
- Assign a visual control Client for the block.
- Set the visual control parameters.

- Server Address – computer name in network or IP address, in which a server is running, to which a client is connecting.
- Port, in which the server is running.
- Address of the data requested from the server.

For communication with external applications in MexBIOS™ Development Studio an interprocessor communication feature is built-in. The feature is based on the socket software interface, and application-specific protocol of data exchange. An external application can be a server one for MexBIOS™ Development Studio, i.e. it can provide data for processing in the environment. Also an external application can be a client one, i.e. it can receive data from MexBIOS™ Development Studio for further processing. As a default the MexBIOS™ Development Studio utilizes a receiving socket, bound to port number 654321, however, if this port is already occupied by another application, MexBIOS™ Development Studio can exploit any other port.
Data exchange between client and server is carried out strictly by application-specific protocol. The protocol essence is shown in fig. 7.
Fig. 7. Data exchange between client and server
After successful connection the client can send requests to server and receive responses from server.
Client request for data outputting is an integer number (32 bits), which value is data address requested from server. Each variable in server has its own address, by which its current value can be requested. The variable address is set in appropriate visual control.
Server response is two numbers. The first number (32 bits) is a validator that indicates validity of the received data. If validator is «0», then the data are valid, if it is «1» – the data address is incorrect (there is no data in this address), if it is «2» – server is not running. The second number (64 bits) is the variable value in floating-point format from the address, sent to server in the request.
An example of requesting and the response processing are shown below.
enum TValidators{ |
vOK = 0, |
vINVALID_INDEX = 1, |
vSERVER_IS_NOT_UPDATING = 2, |
}; |
typedef struct { |
int Validator; |
double Data; |
} |
TResp; |
//----- |
int Addr = 0; |
TResp Resp; |
double SignalValue = 0; |
send(SockClient,(char*)&Addr, sizeof(int), 0 ); |
recv(SockClient,(char*)&Resp, sizeof(TResp), 0 ); |
if(Resp.Validator == vOK) |
SignalValue = Resp.Data; |