Remote Socket
Remote Socket
            
The dialog for this object has no real functionality. It can be used to enter a remote host IP address and port, but normally this would be done directly from a script.
          
            You can enter a remote address here. Normally done directly from a script
            You can enter a remote port number here. Normally done directly from a script
An example ORCAScript follows:
function main() {
  //find the object
  s = find(ORRemoteSocketModel,1); 
  //set the remote address and port
  [s setRemoteHost: "152.2.88.146"];
  [s setRemotePort:4667];
  //connect the socket and wait for it 
  [s connect];
  waituntil([s isConnected]);
  if([s isConnected]){
    //send a request for information and wait for the response
    [s sendString:@"running=[ORRunModel isRunning]"];
    waituntil([s responseExistsForKey:@"running"]);
    print "running=",[[s responseForKey:@"running"]intValue]?"YES":"NO";
    //send a request for information and wait for the response
    [s sendString:@"x=[ORRunModel runNumber]"];
    waituntil([s responseExistsForKey:@"x"]);
    print "x=",[s responseForKey:@"x"];
    //disconnect the socket when done
    [s disconnect];
  }
}
One thing to be aware of is that using the responseForKey method clears the response from the response dictionary and so a follow-up call to get the response for the same key will return nil.