Changeset 3544 in Sophya for trunk/AddOn/TAcq/tsok.cc


Ignore:
Timestamp:
Oct 24, 2008, 12:31:52 PM (17 years ago)
Author:
ansari
Message:

debug classes RawInOutSocketStream et ajout d'envoi/reception de messages de header/trailer - Reza 24/10/2008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/tsok.cc

    r3542 r3544  
    1717
    1818void burawtst();
    19 void serverside();
    20 void clientside(string& servname, string& msg, string& args);
    21 
     19int serverside();
     20int clientside(string& servname, string& msg, string& args);
     21
     22static size_t RIOS_NPAQ = 16;
     23 
     24//---------------------------------------------------------------------------
     25//  main program de test des classes socket  - R. Ansari 2005-2008
     26//---------------------------------------------------------------------------
    2227int main(int narg, char *arg[])
    2328{
     
    2530  if (narg < 2) {
    2631    cout << " Erreur Argument / tsok.cc : Socket class tests \n"
    27          << "    Usage : tsok S/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] \n"
     32         << "    Usage : tsok S/C [servername=localhost] [OPEMsg=Hello] [NLoop,SizeX,SizeY] [RIOS_NPaq=16]\n"
    2833         << "    Ex: tsok S   or  tsok C serverName or \n"
    29          << "        tsok C serverName PPFSOCKET  5  1000,1000 \n"
     34         << "        tsok C serverName PPFSOCKET  5,1000,800 \n"
    3035         << "   S : run tsok as server side \n"
    3136         << "   C : run tsok as client side \n"
     
    4348  string oargs = "1,100,50";
    4449  if (narg > 4) oargs = arg[4];
    45 
     50  if (narg > 5) RIOS_NPAQ = atol(arg[5]);
     51
     52  int rc = 0;
    4653  try {
    4754    SophyaInit(); 
    4855    InitTim();
    49     if (fgserv) serverside();
    50     else if (*arg[1] == 'C') clientside(servname, opemsg, oargs);
     56    if (fgserv) rc=serverside();
     57    else if (*arg[1] == 'C') rc=clientside(servname, opemsg, oargs);
    5158    else burawtst();
    5259  }
    5360  catch(PThrowable exc ) {
    5461    cerr << "tsok-main() , Catched exception: \n" << exc.Msg() << endl;
     62    rc=97;
    5563  }
    5664  catch(std::exception ex) {
    5765    cerr << "tsok-main() , Catched std::exception " << (string)(ex.what()) << endl;
     66    rc=98;
    5867  }
    5968  catch(...) {
    6069    cerr << "tsok-main() , Catched ... ! " << endl;
    61   }
     70    rc=99;
     71  }
     72  cout << " --------- End of tsok.cc Rc=" << rc << " ---------------- " << endl;
    6273}
    6374
    6475
    6576/* --Fonction-- */
    66 void serverside()
    67 {
     77int serverside()
     78{
     79  int rc = 66;
    6880  cout << " ======== tsok.cc / ServerSide ============ " << endl;
    6981  cout << " Creating server socket ... , PortId= " << PORTID << endl;
     
    104116        //      sleep(1);
    105117          {
    106           RawInOutSocketStream sstr(skt);
     118          RawInOutSocketStream sstr(skt, RIOS_NPAQ);
    107119          PInPersist pis(&sstr, false, false);
    108120          pis.GetObject(mx);
     
    113125          {
    114126          // cout << " --- writing back modified mx to socket stream ... " << endl;
    115           RawInOutSocketStream sstr(skt);
     127          RawInOutSocketStream sstr(skt, RIOS_NPAQ);
    116128          POutPersist pos(&sstr, false);
    117129          pos.PutObject(mx);
     
    132144    cout << "ServerSide: Closing current socket ..." << endl;
    133145    skt.Close();
     146    rc = 0;
    134147  }  // fin while(!fgstop)
    135148  cout << " ======= End of tsok.cc / ServerSide ======== " << endl;
     149  return rc;
    136150}
    137151
    138152/* --Fonction-- */
    139 void clientside(string& servname, string& msg, string& args)
    140 {
     153int clientside(string& servname, string& msg, string& args)
     154{
     155  int rc = 77;
    141156  cout << " ======== tsok.cc / ClientSide ============ " << endl;
    142157  cout << "  ServerName= " << servname << " OpeMsg= " << msg << endl;
     
    150165  cout << "  Sending Message : " << buff << endl;
    151166  cli.Send(buff, 256);
     167  rc = 0;
    152168  if (msg == "PPFSOCKET") {
     169    rc = 7;
    153170    int nloop = 1;
    154171    int sx = 100;
     
    170187      {
    171188      // cout << " --- writing mx to socket stream ... " << endl;
    172       RawInOutSocketStream sstr(cli);
     189      RawInOutSocketStream sstr(cli, RIOS_NPAQ);
    173190      POutPersist pos(&sstr, false);
    174191      pos.PutObject(mx);
     
    176193      TMatrix<int_4> mxr;
    177194      {
    178       RawInOutSocketStream sstr(cli);
     195      RawInOutSocketStream sstr(cli, RIOS_NPAQ);
    179196      PInPersist pis(&sstr, false, false);
    180197      pis.GetObject(mxr);
     
    197214    }
    198215    cout << "ClientSide/End of PPFSocket  NPb-Check-returnMatrix=" << npb << " /NLoop=" << nloop << endl; 
     216    if (npb==0) rc=0;
     217    else rc=70;
    199218    float ttms  = tm.TotalElapsedTime();
    200219    if (ttms < 1.e-6) ttms = 1e-6;
     
    205224  cli.Send(buff, 256);
    206225  cout << " ======= End of tsok.cc / ClientSide ======== " << endl;
     226  return rc;
    207227}
    208228
Note: See TracChangeset for help on using the changeset viewer.