Next: , Previous: Removing Registrations, Up: Top


9 Connecting to Pedro

The communication between each client and the Pedro server is via a pair of sockets. One is used for two-way data transfer (e.g. notifications, subscriptions), the other is used for the server to acknowledge messages from the client. This will be a 0 for invalid data from the client and non-zero for valid data.

The creation of the two sockets is done as follows. Examples are given in the code for the Python and Java APIs.

  1. Create a socket in the client (this will be used for acknowledgements)
  2. Use connect to connect the socket to the Pedro server for acknowledgements. Pedro will be listening for the connection on a given port. The default port is 4550.
  3. Read the client ID on this socket (sent by the server as a newline terminated string).
  4. Create another socket in the client (this will be used for data)
  5. Use connect to connect the socket to the Pedro server for data. Pedro will be listening for the connection on the next port after the previous port. The default port is 4551.
  6. Send the client the client ID on the data socket (the same string the server sent above).
  7. Read the status on the data socket. If the connection succeeds the status will be the string "ok\n".