Changeset 3544 in Sophya for trunk/AddOn/TAcq/tsok.cc
- Timestamp:
- Oct 24, 2008, 12:31:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/tsok.cc
r3542 r3544 17 17 18 18 void burawtst(); 19 void serverside(); 20 void clientside(string& servname, string& msg, string& args); 21 19 int serverside(); 20 int clientside(string& servname, string& msg, string& args); 21 22 static size_t RIOS_NPAQ = 16; 23 24 //--------------------------------------------------------------------------- 25 // main program de test des classes socket - R. Ansari 2005-2008 26 //--------------------------------------------------------------------------- 22 27 int main(int narg, char *arg[]) 23 28 { … … 25 30 if (narg < 2) { 26 31 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" 28 33 << " 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" 30 35 << " S : run tsok as server side \n" 31 36 << " C : run tsok as client side \n" … … 43 48 string oargs = "1,100,50"; 44 49 if (narg > 4) oargs = arg[4]; 45 50 if (narg > 5) RIOS_NPAQ = atol(arg[5]); 51 52 int rc = 0; 46 53 try { 47 54 SophyaInit(); 48 55 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); 51 58 else burawtst(); 52 59 } 53 60 catch(PThrowable exc ) { 54 61 cerr << "tsok-main() , Catched exception: \n" << exc.Msg() << endl; 62 rc=97; 55 63 } 56 64 catch(std::exception ex) { 57 65 cerr << "tsok-main() , Catched std::exception " << (string)(ex.what()) << endl; 66 rc=98; 58 67 } 59 68 catch(...) { 60 69 cerr << "tsok-main() , Catched ... ! " << endl; 61 } 70 rc=99; 71 } 72 cout << " --------- End of tsok.cc Rc=" << rc << " ---------------- " << endl; 62 73 } 63 74 64 75 65 76 /* --Fonction-- */ 66 void serverside() 67 { 77 int serverside() 78 { 79 int rc = 66; 68 80 cout << " ======== tsok.cc / ServerSide ============ " << endl; 69 81 cout << " Creating server socket ... , PortId= " << PORTID << endl; … … 104 116 // sleep(1); 105 117 { 106 RawInOutSocketStream sstr(skt );118 RawInOutSocketStream sstr(skt, RIOS_NPAQ); 107 119 PInPersist pis(&sstr, false, false); 108 120 pis.GetObject(mx); … … 113 125 { 114 126 // cout << " --- writing back modified mx to socket stream ... " << endl; 115 RawInOutSocketStream sstr(skt );127 RawInOutSocketStream sstr(skt, RIOS_NPAQ); 116 128 POutPersist pos(&sstr, false); 117 129 pos.PutObject(mx); … … 132 144 cout << "ServerSide: Closing current socket ..." << endl; 133 145 skt.Close(); 146 rc = 0; 134 147 } // fin while(!fgstop) 135 148 cout << " ======= End of tsok.cc / ServerSide ======== " << endl; 149 return rc; 136 150 } 137 151 138 152 /* --Fonction-- */ 139 void clientside(string& servname, string& msg, string& args) 140 { 153 int clientside(string& servname, string& msg, string& args) 154 { 155 int rc = 77; 141 156 cout << " ======== tsok.cc / ClientSide ============ " << endl; 142 157 cout << " ServerName= " << servname << " OpeMsg= " << msg << endl; … … 150 165 cout << " Sending Message : " << buff << endl; 151 166 cli.Send(buff, 256); 167 rc = 0; 152 168 if (msg == "PPFSOCKET") { 169 rc = 7; 153 170 int nloop = 1; 154 171 int sx = 100; … … 170 187 { 171 188 // cout << " --- writing mx to socket stream ... " << endl; 172 RawInOutSocketStream sstr(cli );189 RawInOutSocketStream sstr(cli, RIOS_NPAQ); 173 190 POutPersist pos(&sstr, false); 174 191 pos.PutObject(mx); … … 176 193 TMatrix<int_4> mxr; 177 194 { 178 RawInOutSocketStream sstr(cli );195 RawInOutSocketStream sstr(cli, RIOS_NPAQ); 179 196 PInPersist pis(&sstr, false, false); 180 197 pis.GetObject(mxr); … … 197 214 } 198 215 cout << "ClientSide/End of PPFSocket NPb-Check-returnMatrix=" << npb << " /NLoop=" << nloop << endl; 216 if (npb==0) rc=0; 217 else rc=70; 199 218 float ttms = tm.TotalElapsedTime(); 200 219 if (ttms < 1.e-6) ttms = 1e-6; … … 205 224 cli.Send(buff, 256); 206 225 cout << " ======= End of tsok.cc / ClientSide ======== " << endl; 226 return rc; 207 227 } 208 228
Note:
See TracChangeset
for help on using the changeset viewer.