Board index » cppbuilder » Checking for active connections

Checking for active connections


2003-12-13 12:26:15 AM
cppbuilder56
How do I set up a timer when using server/clientsocket on cBuilder. I want to just send out a test msg with a automated response from server and same from client so to detect when either go down. I think I need some way to intercept msgs from windows.
 
 

Re:Checking for active connections

"Joe" < XXXX@XXXXX.COM >wrote in message
Quote

How do I set up a timer when using server/clientsocket on cBuilder. I want
to just send out a test msg with a automated response from server and same
from client so to detect when either go down. I think I need some way to
intercept msgs from windows.
Don't know how you have your client/server setup, but I usually have a
<header><data>associated with each packet that I send back and forth
between the server and client. Inside of the header I have an unsigned int
called a command...each command has a unique value. This lets the
client/server no what to do with the data, how to process it, etc.
In your case you don't really have any data to send. I would just have a
command called a ping and a command called imAlive. Whenever the
client/server receives a ping command it automatically sets up the header
with the command imAlive and sends it back to whoever was inquiring.
Hope this helps you.
 

Re:Checking for active connections

"JunkMail" < XXXX@XXXXX.COM >wrote in message
Quote
"Joe" < XXXX@XXXXX.COM >wrote in message
news:3fd9fa37$ XXXX@XXXXX.COM ...
>
>How do I set up a timer when using server/clientsocket on cBuilder. I
want
to just send out a test msg with a automated response from server and same
from client so to detect when either go down. I think I need some way to
intercept msgs from windows.

Don't know how you have your client/server setup, but I usually have a
<header><data>associated with each packet that I send back and forth
between the server and client. Inside of the header I have an unsigned
int
called a command...each command has a unique value. This lets the
client/server no what to do with the data, how to process it, etc.
enum CMD {
BROADCAST_MESSAGE = 1,
BROADCAST_CHAT = 2,
PRIVATE_CHAT = 3,
CONNECT = 4,
DISCONNECT = 5,
UPDATE_USERS = 6, // refresh user list
};
class Message
{
public:
char FromUser[40],
ToUser[40],
Text[300];
bool FileLocked;
CMD Cmd;
// methods
Message( void );
Message( const AnsiString & MsgText,
const AnsiString & From,
const AnsiString & To = "" );
private:
};
This is what i'm using Which will eventually call files ect. I can set the
class to test but. How can I have it do it every 30 seconds or so is there a
way I can cut into the timing. As it is now (I think) program just sits
until something happens.
 

{smallsort}

Re:Checking for active connections

You can use a TTimer with its Interval set to 30,000. Then just send a
message whenever the interval goes off.