Seems over the top...
Either have a local var pointing to the socket (make it a TWSocket, not a 
pointer) or just directly access the main form socket.

if mainform.wsocket1.state = wsconnected then 
if mylocalsocketref.state = wsconnected then 

The socket keeps track of its connected status, you dont need to use a 
separate variable.  And if you know the object is a TWSocket, there is no 
reason to use Pointer, use TWSocket.


----- Original Message ----- 
From: "Michael Preslar" <[EMAIL PROTECTED]>
To: "ICS support mailing" <>
Sent: Sunday, January 08, 2006 12:10 AM
Subject: Re: [twsocket] TWSocket.Dup() ?

> What I ended up doing (Which I'll spit out here just in case anyone else
> ever runs into the same situation .. Or maybe theres a better way):
> First define 2 variables..
> chatform.socket : pointer;
> chatform.connected : boolean;
> Then set the chatform variables
> mainform.ConnectToServerClick()
>   if not assigned(chatform.socket) then
>     chatform.socket := @WSocket1;
> mainform.WSocket1.OnSessionConnected()
>   chatform.connected := true;
> mainform.WSocket1.OnSessionClosed()
>   chatform.connected := false;
> Then, finally, in the chatform, when the user does something and needs
> to send data..
> if assigned(socket) and connected then
>   TWSocket(socket).sendstr(s);
> Haven't stress tested it or anything yet, but it works well in my
> testing so far.
> Wilfried Mestdagh wrote:
>> Hello Michael,
>> You dont need to replicate it. Just leave the Socket where it is. In
>> your second form you can have a socket that points to the other socket.
>> Dont drop one on the second form, but just (I called the socket Cli):
>> SecondForm.Cli := MainForm.Cli;
>> and then you call all in the Cli of the second form witch points to the
>> Cli of the mail form.
>> An object variable is just a pointer to the actual object, so you can as
>> many pointers to the same object as you wants.
>> ---
>> Rgds, Wilfried [TeamICS]
> ...
>>> Is this the right way to go? If so, whats the better way to make this 
>>> work?
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto
> Visit our website at

To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to