Applies To:
  • CitectSCADA 1.00, 1.01, 1.10, 1.11, 1.20, 2.00, 2.01

Summary:
Question: How do I use the MsgOpen function on the server side? 

Solution:
When you use MsgOpen on the server side, the handle returned is not the handle to the client - it is only a handle to that server's name. It cannot be the handle to the client, as each server can have many clients, and also when the server is started, the client will not have logged in yet. When the clients login to the sever and start sending their message, the MsgPostServer() function will be called to receive the clients messages. For example, on the server call the MsgOpen function as shown below:

MsgOpen("Alarm", 1, MsgPostServer);
....
INT
FUNCTION MsgPostServer()

INT Type;
INT hMsg;
STRING Str;
hMsg = MsgRead(Type, Str);
! do what the server must do
! send the result back to the client
MsgWrite(hMsg, 0, "Response String");
RETURN 0;

END

When the MsgPostServer() function is called to show a message has arrived, call the MsgRead() function to read the message. MsgRead() will return the handle of the client who sent the message. This way you can use this handle to send back the result to the request send via the client. This also allows a single server post function to handle all the clients at the same time. 


Keywords:
 

Attachments