Пример #1
0
// Message passing routine, used to send and receive a typed message
// Useful for checking the packing and unpacking of message data.
void fakeMessagePassing(TypedMessage &send, TypedMessage &recv)
{
  const int tcpPort = TEST_PORT_BASE+401;
  char ipAddr[] = "127.0.0.1";

  TcpClient tcpClient;
  TcpServer tcpServer;
  SimpleMessage msgSend, msgRecv;

  send.toTopic(msgSend);

  // Construct server

  tcpServer.init(tcpPort);

  // Construct a client
  tcpClient.init(&ipAddr[0], tcpPort);
  tcpClient.makeConnect();  // make tcp client connection

  tcpServer.makeConnect();      // make tcp server connection

  tcpClient.sendMsg(msgSend);   // send message
  tcpServer.receiveMsg(msgRecv); // physically receive message
  recv.init(msgRecv); // copy received message into reference
}