Exemple #1
0
//---------------------------------------------------------------------------
void __fastcall TServerGuiForm::StartButtonClick(TObject *Sender)
{ // This does all the real work.
 // D 1. Check that there are protocols
 // D 2. Check that there is a reply and it can be loaded
 // D 3. Check that there is a server
 // D 4. Load the protocols
 // D 5. Load the server
 // D 6. Enable Stop
 // D 7. Disable Start
 // 8. Update Count
 if (!ProtocolsListBox->Items->Count)
    {
     Application->MessageBox( "Please select protocol and port combination to use", Caption.c_str(), MB_OK );
     return;
    }
 if (ReplyComboBox->ItemIndex==-1)
    {
     Application->MessageBox( "Please select reply type to use", Caption.c_str(), MB_OK );
     return;
    }
 if (ServerComboBox->ItemIndex==-1)
    {
     Application->MessageBox( "Please select server type to use", Caption.c_str(), MB_OK );
     return;
    }
// ServerComboBox->Enabled=False;
// ReplyComboBox->Enabled=False;
// AddButton->Enabled=False;
// RemoveButton->Enabled=False;
// ClearButton->Enabled=False;
 StartButton->Enabled=False;
 StopButton->Enabled=True;
 SettingsPanel->Enabled=False;
 sr=allocate_reply();
 if (!sr) return;
 InitNetwork();
 sp=allocate_protocol();
 if (!sp)
   {
    cleanup( NULL, sr, NULL );
    sr=NULL;
    return;
   }
 ss=allocate_servers( sr, sp );
 if (!ss)
   {
    cleanup( NULL, sr, sp );
    sr=NULL;
    sp=NULL;
    return;
   }
 ActivityTimer->Enabled=True;
 ss->serv->StartServer( ss->handle );
}
//---------------------------------------------------------------------------
void __fastcall TTrafficServerForm::StartButtonClick(TObject *Sender)
{
    if (!ProtocolsListBox->Items->Count)
    {
        Application->MessageBox( "Please select protocol and port combination to use", Caption, TMessageButtons() << smbOK, smsWarning );
        return;
    }
    if (ReplyComboBox->ItemIndex==-1)
    {
        Application->MessageBox( "Please select reply type to use", Caption , TMessageButtons() << smbOK, smsWarning  );
        return;
    }
    if (ServerComboBox->ItemIndex==-1)
    {
        Application->MessageBox( "Please select server type to use", Caption, TMessageButtons() << smbOK, smsWarning );
        return;
    }
    StartButton->Enabled=False;
    StopButton->Enabled=True;
    SettingsPanel->Enabled=False;
    sr=allocate_reply();
    if (!sr)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        return;
    }
    InitNetwork();
    sp=allocate_protocol();
    if (!sp)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        cleanup( NULL, sr, NULL );
        sr=NULL;
        return;
    }
    ss=allocate_servers( sr, sp );
    if (!ss)
    {
        StartButton->Enabled=True;
        StopButton->Enabled=False;
        cleanup( NULL, sr, sp );
        sr=NULL;
        sp=NULL;
        return;
    }
    ActivityTimer->Enabled=True;
    ss->serv->StartServer( ss->handle );
}
Exemple #3
0
int main( int argc, char **argv )
{
  struct client_payload *payload;
  struct client_protocol *protocol;
  struct client_client *client;
  config_info ci( argc, argv );

  if (!ci.isOk())
    {
      if (ci.isVersion())
	{
	  std::cout << ci.getErrorString() << std::endl;
	  return( 0 );
	}
      std::cerr << argv[0] << ":Error " << ci.getErrorString() << std::endl;
      std::cerr << std::endl << ci.help() << std::endl;
      return( 1 );
    }
  std::cout << argv[0] << " Starting" << std::endl;
  std::cout << "Initializing Payloads" << std::endl;
  payload=allocate_payload( &ci );
  if (!payload) return( 2 );
  std::cout << "Initializing Protocols" << std::endl;
  InitNetwork();
  protocol=allocate_protocol( &ci );
  if (!protocol)
    {
      cleanup( payload, NULL, NULL, &ci );
      return( 3 );
    }
  client=allocate_clients( &ci, protocol, ci.getNumClients(), payload, ci.getNumClients() );
  if (!client)
    {
      cleanup( payload, protocol, NULL, &ci );
      return( 4 );
    }
  std::cout << "Starting clients. Press ENTER to end." << std::endl;
  client->clnt->StartClient( client->handle );
  getchar();
  client->clnt->StopClient( client->handle );
  cleanup( payload, protocol, client, &ci );
  std::cout << "Client stopped." << std::endl;
  return( 0 );
}