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");
    }
}
//----< Test Stub to test the sender>--------------------------------
int main() {
	title("Message Passing Communication", '=');
	try
	{
		Sender s;
		Verbose v(true);
		SocketSystem ss;
		SocketConnecter si;
		while (!si.connect("localhost", 9080))
		{
			Verbose::show("client waiting to connect");
			::Sleep(100);
		}

		title("Starting string test on client");
		std::vector<std::string> messageDetails;
		messageDetails.push_back("upload");
		messageDetails.push_back("localhost");
		messageDetails.push_back("9080");
		messageDetails.push_back("Delay.pdf");
		messageDetails.push_back("localhost");
		messageDetails.push_back("9081");

		s.clientFileHandling(si, messageDetails, "input/");
		si.shutDownSend();
	}
	catch (std::exception& ex)
	{
		Verbose::show("Exception caught:", always);
		Verbose::show(std::string("\n  ") + ex.what() + "\n\n");
	}
}
int main()
{
  title("Testing Sender package ", '=');

  try
  {
	Sender sender;
    Verbose v(true);
    SocketSystem ss;
    SocketConnecter si;
	Message msg;
    while (!si.connect("localhost", 9085))
    {
      Verbose::show("client waiting to connect");
      ::Sleep(100);
    }
	// TODO sent
	msg.commandType = UPLOAD;
	msg.senderPort = 9080;
	msg.destAdd = "localhost";
	msg.destPort = 9085;
	msg.fileName = "demo.txt";
	sender.sendFiledata(si, msg, true);
	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");
  }
}
//----< interpret sending message >-----------------
void Sender::interpretingSendingMessage(Message& msg)
{
	string command = msg.getCommand();
	map<string, string> att = msg.getAttributes();
	string destIP = att["destIP"];
	int destPort = atoi(att["destPort"].c_str());
	try{
		displayLine('=');
		Verbose v(true);
		SocketSystem ss;
		SocketConnecter si;
		BlockingQueue<Message> sQueue;
		while (!si.connect(destIP, destPort))
		{
			Verbose::show("client waiting to connect");
			::Sleep(100);
		}
		if (command == "STRING_HANDLING_REQUEST")
		{
			displayString("Demonstrating: Sending string to one peer to other peer");
			displayLine(' ');
			stringHandlingRequest(si, msg);
		}
		if (command == "STRING_HANDLING_REPLY")
		{
			displayString("Demonstrating: Reply from one peer to other peer - String Received");
			displayLine(' ');
			stringHandlingReply(si, msg);
		}
		if (command == "FILE_HANDLING_REQUEST")
		{
			displayString("Demonstrating: Sending file to one peer to other peer");
			displayLine(' ');
			fileHandlingRequest(si, msg);
		}
		if (command == "FILE_HANDLING_REPLY")
		{
			displayString("Demonstrating: Reply from one peer to other peer - File Received");
			displayLine(' ');
			fileHandlingReply(si, msg);
		}
		si.shutDownSend();
	}
	catch (std::exception& ex){
		Verbose::show("  Exception caught:", always);
		Verbose::show(std::string("\n  ") + ex.what() + "\n\n");
	}
	displayLine('-');
}
Example #5
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";
  }
}