int main(int argc, char* argv[])
{
    title("Testing Sockets", '=');

    try
    {
        //Verbose v(true);
        SocketSystem ss;
        SocketConnecter si;
        SocketListener sl(9070, Socket::IP6);
        ClientHandler cp;
        sl.start(cp);
        while (!si.connect("localhost", 9070))
        {
            Verbose::show("client waiting to connect");
            ::Sleep(100);
        }

        title("Starting string test on client");
        clientTestStringHandling(si);
        title("Starting buffer test on client");
        clientTestBufferHandling(si);

        si.sendString("TEST_STOP");

        Verbose::show("\n  client calling send shutdown\n");
        si.shutDownSend();
    }
    catch (std::exception& ex)
    {
        Verbose::show("  Exception caught:", always);
        Verbose::show(std::string("\n  ") + ex.what() + "\n\n");
    }
}
void Sendr::sendAck(std::string sourceIp, size_t sourcePort, std::string destIp, size_t destPort)
{
	SocketSystem ss;
	SocketConnecter si;

	while (!si.connect(destIp, destPort))
	{
		std::cout << "Client waiting to connect \n";
		::Sleep(100);
	}
	si.sendString("ACKNOWLEDGE");
	std::string ack_str = "Acknowledgement from server..";
	si.sendString(ack_str);
	std::cout << "\n---------------------------------";
	std::cout << "\ndestIP   :: " << destIp;
	std::cout << "\ndestPort :: " << destPort << "\n";
	std::cout << "Sending Acknowledgement.....\n";
	std::cout << "-------------------------------\n";
}
Exemplo n.º 3
0
int main(int argc, char* argv[])
{
  Show::attach(&std::cout);
  Show::start();
  Show::title("Testing Sockets", '=');

  try
  {
    SocketSystem ss;
    SocketConnecter si;
    SocketListener sl(9070, Socket::IP6);
    ClientHandler cp;
    sl.start(cp);
    while (!si.connect("localhost", 9070))
    {
      Show::write("\n  client waiting to connect");
      ::Sleep(100);
    }

    Show::title("Starting string test on client");
    clientTestStringHandling(si);
    Show::title("Starting buffer test on client");
    clientTestBufferHandling(si);

    si.sendString("TEST_STOP");

    Show::write("\n\n  client calling send shutdown\n");
    si.shutDownSend();
    sl.stop();
  }
  catch (std::exception& ex)
  {
    std::cout << "\n  Exception caught:";
    std::cout << "\n  " << ex.what() << "\n\n";
  }
}