🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2944

Re: TWinSocketStream Read in BYTE buffer

#2944
From: Maurice Anderson
Date: Sun, 25 Dec 2005 20:54
38 lines
2657 bytes
> Allocate a larger buffer and then copy the contents of the two into it.

How would I do that?

pBuf += test; <- doesn't work
test+= pBuf ; <- doesn't work

> But why would you want to concatenate the two types?  What EXACTLY are you
trying to accomplish?

I am "trying" to implement your idea to send the type(binary or text) and
byte size to the server for pre-processing so that it knows how to handle
the data sent.  So for binary data, I want to server to save the data back
as a file in it's original format and for text, I want to display it as a
popup message or something.  So the 'frame' would look something like this
format:  [type code][data length][file name][data].  So my code would look
something like this:

char type[5] = "0x01"; <- type code
char length[25] = "192"; <- type code (in bytes)
char filename[15] = "boot.ini"; <- type code (in bytes)

TMemoryStream *DataFromFile = new TMemoryStream;
DataFromFile ->LoadFromFile("c:\\boot.ini");

  /* Convert it to BYTES and concantenate the fields into 1 'frame' */
BYTE *buffer2 = (BYTE *)DataFromFile ->Memory;
buffer2 += ( type + length + filename);

  /* Display it in a memo to view how the frame looks */
Memo1->Lines->Add((char *)Strm->Memory);

ClientSocket1->Socket->SendBuf(buffer2, x); // x = number of total bytes to
send over

I know I don't have it all together here, but I am hoping that whatever
example code I get, I can just learn from and modify it to fit my
application.  I am pretty good at doing that.
Technical Details
Message-ID: <43af06d7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!news.musoftware.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <43ac3d34$1@newsgroups.borland.com> <43ac6028$1@newsgroups.borland.com> <43acc4c5$1@newsgroups.borland.com> <43ae5b51$1@newsgroups.borland.com> <43aeebe1$1@newsgroups.borland.com> <43aef70e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,74cdc31c66b3abd9
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Maurice Anderson" <mauriceanderson@hotmail.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <43ac3d34$1@newsgroups.borland.com> <43ac6028$1@newsgroups.borland.com> <43acc4c5$1@newsgroups.borland.com> <43ae5b51$1@newsgroups.borland.com> <43aeebe1$1@newsgroups.borland.com> <43aef70e$1@newsgroups.borland.com>
Subject: Re: TWinSocketStream Read in BYTE buffer
Date: Sun, 25 Dec 2005 12:54:26 -0800
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 64.30.203.223
Message-ID: <43af06d7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1135544023 64.30.203.223 (25 Dec 2005 12:53:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!news.musoftware.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail