🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Using ReceiveBuff() from a client socket app?

#1574
From: Remy Lebeau (TeamB)
Date: Tue, 02 Jan 2007 18:20
30 lines
2031 bytes
"chris" <nospam@help.com> wrote in message
news:459a9fb9$1@newsgroups.borland.com...

> I have been temporarily using "void * buffer" just to bring the
> information in as I step through my code.

The issue Bob was trying to point out to you is that you are reading
into a void* pointer that is not actually pointing anywhere.  You did
not allocate any memory for it.

> Also, I am trusting that the very first piece of info sent
> from the server is the first 4 bytes.

Don't trust anything.  That is a good way for a middleman attacker to
crash your code.  Or just connecting to the wrong server (user error)
could do it as well.  Always validate everything you send/receive.
You may want to prefix your packets with an actual header that
includes more information than just the packet size.  You could put
checksum information in it to verify the data before you try to use
it.

> I was trying to make my client code be close to a mirror image of
> the server code

It can't be a mirror when using non-blocking sockets.  The reading is
very different than the writing.


Gambit
Technical Details
Message-ID: <459aa6af$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <459a8f2a$1@newsgroups.borland.com> <ku4lp294ehvbh229hj8pdhpdfp31rqa7l0@4ax.com> <459a9fb9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,41e3cddf77758900
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <459a8f2a$1@newsgroups.borland.com> <ku4lp294ehvbh229hj8pdhpdfp31rqa7l0@4ax.com> <459a9fb9$1@newsgroups.borland.com>
Subject: Re: Using ReceiveBuff() from a client socket app?
Date: Tue, 2 Jan 2007 10:20:23 -0800
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <459aa6af$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1167763119 75.83.34.171 (2 Jan 2007 10:38:39 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail