[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [C/C++] TCP/IP byte-order kommunikation







John Mørck Hansen <sslug@sslug> wrote on 30-01-2004 18:00:44:

> Det er sikkert rigtigt men ville denne kode ikke kunne bruges. Jeg har
> ikke testet den på nogen måde. Så der er sikkert fejl. I øvrigt er det
> også kun et eksempel... jeg kunne ikke finde på at bruge det "in real
> life".

B.S har et meget meget godt eksempel i The C++ Programming Language 3. ed.

Hvor han definerer en Io_obj<...> template.

Trikket er at der skal være symmetri mellem input og output funktioner
specialiseret for hvert objekt -- det er der f.eks. ikke ved builtin
types/std::string.
[EX]
some_iostringstream << (some_int= 1) << (another_int= 2);
some_iostringestream >> some_int >> another_int; // non-symmetry some_int
== 12 && another_int in error
[!EX]

B.S. skriver "implementation of Io_obj<[builtin_type]> is left as an
excercise"

En af de teknikker der vendes er at sende typename som Io_obj<std::string>
og lade modtageren slå op i map fra typename til classens input function og
vha. en factory returnere et Io_obj<.> af den rigtige type.


mht. til TCP/IP har jeg implementeret min egen basic_socketbuf<...> så jeg
kan skrive
[EX]
some_isocketstream >> some_var;
any_ostream << some_var;
[!EX]
fuldkommen symetrisk ved en connection orienteret connection-style (jeg er
hamrende ligeglad om man skriver til/fra terminal, fil eller vha tcpip).


Peter Makholms forslag om at kikke til ASN.1 som protokol for data vil jeg
med mere end almindelig interesse se nærmere på men umidelbart vil jeg give
Egon Andersen ret i at det nok vil tage mere end en halv time at sætte sig
ind i.


Med venlig hilsen / Kind regards
Nils Åke Ljunggren
Senior Developer

IntraVision - www.intravision.dk


Office Phone : +45 7023 2340
Office Fax: +45 7023 2349
Mobile : +45 2613 9966

Mail : sslug@sslug
http://www.intravision.dk
OnLine Meeting Center: http://sametime.intravision.biz/stcenter.nsf


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *