Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by Lesley Anne
Mon, 09 Oct 2006 17:52
Can I check for invalid TCustomWinSocket pointers?
Author: Lesley Anne
Date: Mon, 09 Oct 2006 17:52
Date: Mon, 09 Oct 2006 17:52
10 lines
1557 bytes
1557 bytes
I have a TServerSocket that gets queries from client connections and sends a response back to the socket that requested it. The problem is that it often has to check external databases before it can formulate its response, so there can be a brief delay before it has something to send back. If during that time the client has disconnected, it causes an access violation when I try to send back the response to a socket that no longer exists. I'd like to be able to check whether my TCustomWinSocket* still points to a valid active socket before I try sending the response to it. Is there a good way to do that?
Re: Can I check for invalid TCustomWinSocket pointers?
Author: Remy Lebeau (TeamB)
Date: Mon, 09 Oct 2006 19:40
Date: Mon, 09 Oct 2006 19:40
15 lines
1540 bytes
1540 bytes
"Lesley Anne" <mspfila-ng@yahoo.com> wrote in message news:452a8c67$1@newsgroups.borland.com... > I'd like to be able to check whether my TCustomWinSocket* still > points to a valid active socket before I try sending the response to it. > Is there a good way to do that? The only way to validate the pointer is to see if it still exists in the server's Connection's list. Otherwise, you will have to update your code to set your stored pointers to NULL when the OnDisconnect event occurs, and then have your database code check for NULL before writing to the socket. Gambit
Re: Can I check for invalid TCustomWinSocket pointers?
Author: Lesley Anne
Date: Mon, 09 Oct 2006 21:17
Date: Mon, 09 Oct 2006 21:17
20 lines
1919 bytes
1919 bytes
Remy Lebeau (TeamB) wrote: > > The only way to validate the pointer is to see if it still exists > in the server's Connection's list. OK, thanks. I added a function to check for it that way and it seems to work. > Otherwise, you will have to update your code to set your > stored pointers to NULL when the OnDisconnect event occurs, and then > have your database code check for NULL before writing to the socket. The search for matching pointers is a little more complicated there and would require additional indexing on my database of outstanding transactions, so I'm going to start off with the other method. This is worth keeping in mind, though, because I should be getting more response events than disconnect events. If I need to start fine tuning this app for throughput issues, I'll check whether I get better performance by updating pointers on the (less frequent) OnDisconnect event.
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