Errata in article "Network Coms with BCB Part 2".

This is the forum to discuss the Journal's content, article suggestions, etc.

Moderator: 2ffat

Errata in article "Network Coms with BCB Part 2".

Postby gtokas » Sat Aug 26, 2006 8:25 am

The rule says "In every 10 lines of code there ARE at least one error".
The above proved true at almost any program.
So...
If any of you tried the updated server program you will notice that when a client disconnects server project reports a "Stack Overflow".
And that is because at the user class we use Socket->Close() at 2 sections:
1.
void __fastcall User::SocketEvent(
TObject *Sender,
TCustomWinSocket *Socket,
TSocketEvent Event)
{
//Code Here
if(Event == seDisconnect) {
Socket->Close();
Socket = NULL;
Handle = 0;
}
}
2.
void __fastcall User::ErrorEvent(
TObject *Sender,
TCustomWinSocket *Socket,
TErrorEvent Error, int &ErrorCode)
{
ErrorCode = 0;
Socket->Close();
Socket = NULL;
Handle = 0;
}

So every time we call Socket->Close() the seDisconnect event triggered and we are in a never ending loop results to the Stack Overflow...
Just comment those 2 lines and everything will work fine again.

George Tokas.

P.S. I would like a bit of feedback about this.
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Network Comms

Postby tonus » Thu Mar 22, 2007 9:23 am

George,

I've copied your net comms program and meet problems in the server part:
1. The compiler complains about:
class TForm1 : public TForm
{
__published: // IDE-managed Components
TServerSocket *Server;

Form1->Server does not have a corresponding component. Remove the declaration.

2. If I ignore that message and run this program it crashes, me doing nothing, exception class EAccessViolation. The CPU-window is at:
Scktcomp::TAbstractSocket::SetActive:

I'm using BCB5Prof, and really don't have a clue, a working sample would be so welcome ...

Regards,
Anton.

P.S.
Your footer looks to me as a decimal to hex conversion.
That may explain my age....
tonus
 

Postby gtokas » Thu Mar 22, 2007 9:44 am

Hi there,
Open the form of the server part.
Delete the server socket, if exists, drop a new TServerSocket and rename it to "Server" for compliance with the code.
That errors are very often when copying code to a new project.
Inform me about the result.

George Tokas.
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Postby gtokas » Thu Mar 22, 2007 9:49 am

>>Your footer looks to me as a decimal to hex conversion.
Zilog Z80 code dated from 1982.
Incrementing a decimal value till reach 80.
Z80 has a very handy decimal adjust command (DAA).
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Compiler satisfied.

Postby tonus » Fri Mar 23, 2007 2:45 am

George, thanks for your prompt reply!
You pointed exactly to the problem: the naming of component.

Regards,
Anton.

P.S.
Mixed up your footer with this piece of code that prints nibbles (half bytes) as hex characters: (the only use I had for DAA in those days ...)
Nibble
push af
daa
add a,F0h
adc a,40h

PRINT_CHAR ; prints ASCII character in A

pop af
Last edited by tonus on Fri Mar 23, 2007 9:27 am, edited 1 time in total.
tonus
 

It WORKS!

Postby tonus » Fri Mar 23, 2007 8:13 am

Something that gives no clues is: that if you type in the code directly you NEED TO click on the corresponding events in the object inspector once. So they get 'attached' to their objects.
I compiled the server without this and it just sat there, just doing nothing.
As it should be ....

And slowly, step by step, I'm getting understanding of what is happening.
My thanks to George Tokas.


Anton.
tonus
 


Return to Articles

Who is online

Users browsing this forum: No registered users and 2 guests