> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: 17 January 2007 22:12
> To: twsocket@elists.org
> Subject: Re: [twsocket] WinSock error 10035 with TWSocketServer
> 
> Hi Dan,
> 
> > > >   TWSocketClient* Client = dynamic_cast<TWSocketClient*>(Sender);
> > > >   AnsiString msg = Client->ReceiveStr();
> > >
> > > The first line will execute, I think the second line will generate an
> > > exception here. I4m not sure. Did you have it into an exception block
> ?
> > >
> > > As far as I know the dynamic_cast is a kind of equivalent for 4is4 or
> > > 4as4 operators in Delphi and some other languages. It is not the same
> as
> > > a type cast. I even think it will evaluate to false (null) because
> > > Sender is of type TObject (yeah it "is" TWSocketClient, but compiler
> > > dont know that).
> >
> > A dynamic cast is safer.  Yes its similar to Delphi4s as/is operators.
> In
> > this case, this a pointer dynamic cast (rather than a reference), it
> will
> > return null/nil if Sender isn4t really a TWSocketClient, and the code
> should
> > then check for this.  An alternative is to use a reference:
> >
> >  TWSocketClient& Client = dynamic_cast<TWSocketClient&>(Sender);
> 
> But Sender is a pointer - I didn't think you could typecast a pointer to a
> reference.
> 
> Regards,
> 
> Bevan
> 

Oops, you're right. *Sender.

Dan


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to