🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
6 messages
6 total messages Started by Vladimir Stefanovic Sat, 07 Aug 2004 19:38
I need some suggestions and oppinion for sending data
#5566
Author: Vladimir Stefanovic
Date: Sat, 07 Aug 2004 19:38
49 lines
2294 bytes
Hi,

I have 4 data structures to be sent from one service
to the other via TClientSocket & TServerSocket. Those
structures are fragments of database.

Struct 1 schema (Columns=4; Rows=Struct1->Count )

1 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
2 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
3 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
(Y and Z are not with fixed filed length)

Struct 2, 3 & 4 schema (Columns=3, Rows=StructN->Count )

1 QQQQQQ WWWWWWWWWWWWWWWWWWW
2 QQQQQQ WWWWWWWWWWWWWWWWWWW
(Q and W are not with fixed filed length)


I have two questions:

1) How could I send those data? I think I should
first make one specialy formated buffer which I
should transfer in the usual manner (in fragments)
and on the server side (when all received) to use
the same algorythm to decrypt data to the same
structures.

In such situations I usually made some special marks
which I can later used to separate entities like:

[$S1$] 1 [$S1$] X [$S1$] YYY... [$S1$] ZZZ...
[$S2$] 1 [$S2$] QQQQQ... [$S2$] WWW...

... in short - [$S1$] means that the data belongs to the
first struct and because there are 4 columns in struct1
there is no ned for the special mark for the end of row.

Can you suggest me something easier and better?

2) If there are 100 rows (in all 4 structures), and
not more than 100 chars in a row, how much time will
take sending data in 100 MBit LAN that has not much
traffic.


Best regards,
Vladimir Stefanovic
Re: I need some suggestions and oppinion for sending data
#5569
Author: Daniele Borini
Date: Sun, 08 Aug 2004 02:14
69 lines
3448 bytes
hi,
i think you should send data as string. sending rows one by one, you'll 
receive rows one by one, if you use TCP (not UDP) it's not your problem 
to rebuild and reorder received data, it's a TCP stuff to ensure packets 
"chunk" rebuild. by sending rows one by one you just need to something like:

1@1 X YYYYYYYY ZZZZZZZZZZZZZZZZ@
2@1 QQQQQQQQ WWWWWWWWWWWWWWWWWW@

first character indicates what kind of schema will follow between two 
'@' characters. the rest it's just a simple string parser...
'bout speed there aren't sure numbers, just make some tests: try to send 
a very large amount of data, every second test how  many byte (or MByte) 
has been sent then calculate the average value, by this way you'll 
always have a good estimation of network speed and transfer times...
Good luck Daniele

> Hi,
> 
> I have 4 data structures to be sent from one service
> to the other via TClientSocket & TServerSocket. Those
> structures are fragments of database.
> 
> Struct 1 schema (Columns=4; Rows=Struct1->Count )
> 
> 1 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
> 2 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
> 3 X YYYYYYYYYY ZZZZZZZZZZZZZZZZZ
> (Y and Z are not with fixed filed length)
> 
> Struct 2, 3 & 4 schema (Columns=3, Rows=StructN->Count )
> 
> 1 QQQQQQ WWWWWWWWWWWWWWWWWWW
> 2 QQQQQQ WWWWWWWWWWWWWWWWWWW
> (Q and W are not with fixed filed length)
> 
> 
> I have two questions:
> 
> 1) How could I send those data? I think I should
> first make one specialy formated buffer which I
> should transfer in the usual manner (in fragments)
> and on the server side (when all received) to use
> the same algorythm to decrypt data to the same
> structures.
> 
> In such situations I usually made some special marks
> which I can later used to separate entities like:
> 
> [$S1$] 1 [$S1$] X [$S1$] YYY... [$S1$] ZZZ...
> [$S2$] 1 [$S2$] QQQQQ... [$S2$] WWW...
> 
> ... in short - [$S1$] means that the data belongs to the
> first struct and because there are 4 columns in struct1
> there is no ned for the special mark for the end of row.
> 
> Can you suggest me something easier and better?
> 
> 2) If there are 100 rows (in all 4 structures), and
> not more than 100 chars in a row, how much time will
> take sending data in 100 MBit LAN that has not much
> traffic.
> 
> 
> Best regards,
> Vladimir Stefanovic
> 
> 
> 
Re: I need some suggestions and oppinion for sending data
#5570
Author: Vladimir Stefanovic
Date: Sun, 08 Aug 2004 06:03
35 lines
1792 bytes
Thanks Daniele,

I'll consider your suggestions.

Now, I have found in the '...students' group some code that Remy
supplied for 'Easy way to save struct data to file':

These are fragments, and I think I can use it after slite modifications

[...]
    void WriteAnsiString(FILE *File, const AnsiString &Str)
    {
        int len = Str.Length();
        fwrite(&len, sizeof(int), 1, File);
        if( len > 0 )
            fwrite(Str.c_str(), sizeof(char), len, File);
    }

[...]
    void ReadAnsiString(FILE *File, AnsiString &Str)
    {
        int len = 0;
        fread(&len, sizeof(int), 1, File);
        if( len > 0 )
        {
            Str.SetLength(len);
            fread(Str.c_str(), sizeof(char), len, File);
        }
        else
            Str = "";
    }


Best regards,
Vladimir Stefanovic
Re: I need some suggestions and oppinion for sending data
#5471
Author: Daniele Borini
Date: Sun, 08 Aug 2004 09:49
47 lines
2272 bytes
yes, but i suggest you to use only one write such as:

AnsiString s=AnsiString('1')+rec_str;
fwrite(s.c_str(),sizeof(char),len,File);

that's 'couse on the other side of the transmission u'll get data with 
only one read.. more faster...

Vladimir Stefanovic wrote:
> Thanks Daniele,
> 
> I'll consider your suggestions.
> 
> Now, I have found in the '...students' group some code that Remy
> supplied for 'Easy way to save struct data to file':
> 
> These are fragments, and I think I can use it after slite modifications
> 
> [...]
>     void WriteAnsiString(FILE *File, const AnsiString &Str)
>     {
>         int len = Str.Length();
>         fwrite(&len, sizeof(int), 1, File);
>         if( len > 0 )
>             fwrite(Str.c_str(), sizeof(char), len, File);
>     }
> 
> [...]
>     void ReadAnsiString(FILE *File, AnsiString &Str)
>     {
>         int len = 0;
>         fread(&len, sizeof(int), 1, File);
>         if( len > 0 )
>         {
>             Str.SetLength(len);
>             fread(Str.c_str(), sizeof(char), len, File);
>         }
>         else
>             Str = "";
>     }
> 
> 
> Best regards,
> Vladimir Stefanovic
> 
> 
> 
Re: I need some suggestions and oppinion for sending data
#5472
Author: Vladimir Stefanovic
Date: Sun, 08 Aug 2004 11:47
17 lines
1523 bytes
> AnsiString s=AnsiString('1')+rec_str;
> fwrite(s.c_str(),sizeof(char),len,File);
>
> that's 'couse on the other side of the transmission u'll get data with
> only one read.. more faster...

Yes, that could be much more efficient than the soulution I presented
in previous post. I'm now considering the saving in this string format...

   "  %s  \t  %s  \t  %s  \t  %s  \r\n  " (without spaces)

... I think this could be used in both fprintf() & fscanf() for
reading and writing.


Best regards,
Vladimir Stefanovic
Re: I need some suggestions and oppinion for sending data
#5473
Author: Daniele Borini
Date: Sun, 08 Aug 2004 16:17
23 lines
1750 bytes
yes, it's a good way
Vladimir Stefanovic wrote:
>>AnsiString s=AnsiString('1')+rec_str;
>>fwrite(s.c_str(),sizeof(char),len,File);
>>
>>that's 'couse on the other side of the transmission u'll get data with
>>only one read.. more faster...
> 
> 
> Yes, that could be much more efficient than the soulution I presented
> in previous post. I'm now considering the saving in this string format...
> 
>    "  %s  \t  %s  \t  %s  \t  %s  \r\n  " (without spaces)
> 
> ... I think this could be used in both fprintf() & fscanf() for
> reading and writing.
> 
> 
> Best regards,
> Vladimir Stefanovic
> 
> 
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads