regarding checking the state of the socket

message unavailable

Can someone tel me how to do a heart beat to check the state of the socket…
is it like sending/receiving
messages constantly? I noticed that if Select() returns me 1, that means
there is something to read…
but if I do a read afterthat, read returns me 0 if the client has dropped
out of the communication…
is this a valid test?
like
if (select (…))
{ if (read (…) = = 0)
perror (“client is dead”);
else
cout <<"Msg is == "<< Msg "
}

“ran zhang” <rzhang@vamcointernational.com> wrote in message
news:a3e904$72t$1@inn.qnx.com

Can someone tel me how to do a heart beat to check the state of the
socket…
is it like sending/receiving
messages constantly? I noticed that if Select() returns me 1, that means
there is something to read…
but if I do a read afterthat, read returns me 0 if the client has dropped
out of the communication…
is this a valid test?

No,

There are many ways to deal with that. One that come to mind it
to have the “other side” send data every 30 seconds for example,
the setup a timeout in select to detect if no data was received
for at least 30 secs.

like
if (select (…))
{ if (read (…) = = 0)
perror (“client is dead”);
else
cout <<"Msg is == "<< Msg "
}

\

“Mario Charest” <goto@nothingness.com> wrote in message
news:a3e9vh$7ia$1@inn.qnx.com

“ran zhang” <> rzhang@vamcointernational.com> > wrote in message
news:a3e904$72t$> 1@inn.qnx.com> …
Can someone tel me how to do a heart beat to check the state of the
socket…
is it like sending/receiving
messages constantly? I noticed that if Select() returns me 1, that
means
there is something to read…
but if I do a read afterthat, read returns me 0 if the client has
dropped
out of the communication…
is this a valid test?

No,

There are many ways to deal with that. One that come to mind it
to have the “other side” send data every 30 seconds for example,
the setup a timeout in select to detect if no data was received
for at least 30 secs.

like
if (select (…))
{ if (read (…) = = 0)
perror (“client is dead”);
else
cout <<"Msg is == "<< Msg "
}




\

According to W. Richard Stevens’ UNIX Network Programming one of the
conditions for select indicating a socket is reading for reading is if “the
read-half of the connection is closed. A read operation on the socket will
not block and will return 0.” This handles the normal closure of remote
connections but does not handle abnormal disconnects such as the crash of
the remote host, etc. The SO_KEEPALIVE socket option can be enabled to help
in detecting the abnormal cases but it only kicks in after 2 Hrs of
inactivity. A read in the abnormal break should return -1 with errno set.

Please see reply in qdn.public.newuser group…in the future please try not
to cross-post as it make makes a mess of the newsgroups and makes it harder
for people to find the information the are looking for.

Thanks,

Joe

“Lily” <fanxm0712@yahoo.ca> wrote in message
news:b7fdli$p73$2@inn.qnx.com

I am used to program with Watcom C++ 10.6 under QNX 4, and I am going to
migrating the program to QNX 6 now. But I don’t know how to write the
file “makefile” for my program if the main file includes some other
classe files. The file “makefile” in QNX 4.2 is:

test:test.o sfile1.o sfile2.o sfile3.o
cc -T1 test.o sfile1.o sfile2.o sfile3.o -o test

test.o: test.cpp
cc -c test.cpp

sfile1.0: sfile1.cpp
cc -c sfile1.cpp

sfile2.o: sfile2.cpp
cc -c sfile2.cpp