🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages Started by Luca Wed, 01 Sep 2004 14:29
TClientSocket
#5393
Author: Luca
Date: Wed, 01 Sep 2004 14:29
25 lines
1595 bytes
I' m working with an old version of c++ builder (3.0 Client/Server Suite)on Windows Xp and 2000 and I have a problem with a 
TClientSocket instance. My application is a chat, and I use a TClientSocket for sending messages and a TServerSocket 
for receving messages. The problem is that after a period of normal use a ESocketException is raised because 
I try to change the Address property while the Active attribute of the TClientSocket is true, even if the Close method has been invocated. 
From this point is impossible to change the socket state even with additional calls to the Close method.

This is my code fragment :

    Client->Close();

    try
    {
        Client->Address = address;
        Client->Host = host;
    }
    catch(ESocketError *e)
    {
        ShowMessage("Error");
    }
    Client->Open();
    
Thanks for your help

Luca
Re: TClientSocket
#5395
Author: Vladimir Stefanovic
Date: Wed, 01 Sep 2004 16:17
35 lines
1695 bytes
> I try to change the Address property while the Active attribute
> of the TClientSocket is true, even if the Close method has
> been invocated.

Active has to be false if you want to change address. I'm the
absolute beginner is sockets, but lets try (with my experiences).

I have similar problems when this skeleton is applied:

Close()
ChangeAttributes()
Open()
Send()

I found smarter to WAIT for appropriate events to be triggered
before I take ANY action (like changing/sending). That means:

Close();
OnDisconnect() { ChangeAttributes() }
Open();
OnConnect() { Send() }

... or similar.


>         Client->Address = address;
>         Client->Host = host;

Are you always changing BOTH address & host? Are you sure
that the problem is not in connection with the passed values?



Best regards,
Vladimir Stefanovic
Re: TClientSocket
#5406
Author: Luca
Date: Fri, 03 Sep 2004 13:13
58 lines
2162 bytes
"Vladimir Stefanovic" <spam@not.needed> wrote:
>> I try to change the Address property while the Active attribute
>> of the TClientSocket is true, even if the Close method has
>> been invocated.
>
>Active has to be false if you want to change address. I'm the
>absolute beginner is sockets, but lets try (with my experiences).
>
>I have similar problems when this skeleton is applied:
>
>Close()
>ChangeAttributes()
>Open()
>Send()
>
>I found smarter to WAIT for appropriate events to be triggered
>before I take ANY action (like changing/sending). That means:
>
>Close();
>OnDisconnect() { ChangeAttributes() }
>Open();
>OnConnect() { Send() }
>
>... or similar.
>
>
>>         Client->Address = address;
>>         Client->Host = host;
>

Thanks Vladimir for your help but unfortunately the problem still exists .

I tryed to delete the TClientSocket instance and to instantiate a new object; code follows:  

delete clientSocket;
clientSocket = new TClientSocket(this) 

where "this" is the form where the TClientSocket component is located; but this code doesn't work, do you have any suggestion ?

Thanks in advance

Best Regards 

Luca 



>Are you always changing BOTH address & host? Are you sure
>that the problem is not in connection with the passed values?
>
>
>
>Best regards,
>Vladimir Stefanovic
>
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads