How to check the Connection Status | developer.brewmp.com How to check the Connection Status | developer.brewmp.com

Developer

How to check the Connection Status

Forums:

Hello all
We want to know whether the server has closed the connection, before trying to write on a closed socket.
The problem is , we fire a request to a server and , on response we take a action and finally inform the server about the action taken. Now before we inform the server about the action taken, if the server closes the socket we want to know about this, before we try to write on a closed socket.
Can any one of you comment on this point.

Thanks
Gopal

Best prictice is to right to the socket and check then check the status.

Best prictice is to right to the socket and check then check the status.

gopal_vm wrote:Hello all
We want to know whether the server has closed the connection, before trying to write on a closed socket.
The problem is , we fire a request to a server and , on response we take a action and finally inform the server about the action taken. Now before we inform the server about the action taken, if the server closes the socket we want to know about this, before we try to write on a closed socket.
Can any one of you comment on this point.
Thanks
Gopal
Often the response you see on the client side depends upon
how you closed the socket on the server side.

gopal_vm wrote:Hello all
We want to know whether the server has closed the connection, before trying to write on a closed socket.
The problem is , we fire a request to a server and , on response we take a action and finally inform the server about the action taken. Now before we inform the server about the action taken, if the server closes the socket we want to know about this, before we try to write on a closed socket.
Can any one of you comment on this point.
Thanks
Gopal
Often the response you see on the client side depends upon
how you closed the socket on the server side.

jmiller2 wrote:Often the response you see on the client side depends upon
how you closed the socket on the server side.
Hello Jmiller
[INDENT]The scenario is that. We request for some settings and on response from server we display a consent dialog box. If the user takes more than 60 sec (it may vary, not known to BREW client) to respond to this dialog box, the server will close the connection. Now after the user response we have to send the feedback to the server (if the connection is not closed). If the connection is closed the client will not open a socket, instead it will display some msg and proceed.[/INDENT]
[INDENT]In this condition we first want to know whether the connection is still alive or closed by the server.[/INDENT]
Regards
Gopal

jmiller2 wrote:Often the response you see on the client side depends upon
how you closed the socket on the server side.
Hello Jmiller
[INDENT]The scenario is that. We request for some settings and on response from server we display a consent dialog box. If the user takes more than 60 sec (it may vary, not known to BREW client) to respond to this dialog box, the server will close the connection. Now after the user response we have to send the feedback to the server (if the connection is not closed). If the connection is closed the client will not open a socket, instead it will display some msg and proceed.[/INDENT]
[INDENT]In this condition we first want to know whether the connection is still alive or closed by the server.[/INDENT]
Regards
Gopal

My client will use one socket for a set of http request / response pairs.
But if the 2 http request / response pairs' interval longer than 15 seconds, the server will close the socket. ISOCKET_Write() will succeed, but ISOCKET_Read() will return 0, indicate that there is no more data to be received or the peer has shut down the connection.
Is that right?

My client will use one socket for a set of http request / response pairs.
But if the 2 http request / response pairs' interval longer than 15 seconds, the server will close the socket. ISOCKET_Write() will succeed, but ISOCKET_Read() will return 0, indicate that there is no more data to be received or the peer has shut down the connection.
Is that right?

zjzhao wrote:My client will use one socket for a set of http request / response pairs.
But if the 2 http request / response pairs' interval longer than 15 seconds, the server will close the socket. ISOCKET_Write() will succeed, but ISOCKET_Read() will return 0, indicate that there is no more data to be received or the peer has shut down the connection.
Is that right?
It sounds like you are using some sort of web server rather than your own
socket server. In this case, it is likely that you will have consult the
documentation for the server settings and adjust them to your needs.
If this is not the case then you should be able to solve the problem by
devising a proper request/response message pairing.

zjzhao wrote:My client will use one socket for a set of http request / response pairs.
But if the 2 http request / response pairs' interval longer than 15 seconds, the server will close the socket. ISOCKET_Write() will succeed, but ISOCKET_Read() will return 0, indicate that there is no more data to be received or the peer has shut down the connection.
Is that right?
It sounds like you are using some sort of web server rather than your own
socket server. In this case, it is likely that you will have consult the
documentation for the server settings and adjust them to your needs.
If this is not the case then you should be able to solve the problem by
devising a proper request/response message pairing.

gopal_vm wrote:Hello Jmiller
[INDENT]The scenario is that. We request for some settings and on response from server we display a consent dialog box. If the user takes more than 60 sec (it may vary, not known to BREW client) to respond to this dialog box, the server will close the connection. Now after the user response we have to send the feedback to the server (if the connection is not closed). If the connection is closed the client will not open a socket, instead it will display some msg and proceed.[/INDENT]
[INDENT]In this condition we first want to know whether the connection is still alive or closed by the server.[/INDENT]
Regards
Gopal
In such a case you should do one of several things:
(in addition to possibly tweaking your server settings)
1. Keep the connection open until the user responds by
sending your own ping packets to the server every so often.
(Method depends upon your server software and settings).
2. Close the connection upon displaying this dialog box, and
then immediately open up a new connection once the user has
finished entering data.
If it is likely that the user will take some time to respond to the
dialog then you will probably want to go with the second method.
You could also put a time limit on how long the user has to
respond to the dialog box and then perform some action
when the time expires.

gopal_vm wrote:Hello Jmiller
[INDENT]The scenario is that. We request for some settings and on response from server we display a consent dialog box. If the user takes more than 60 sec (it may vary, not known to BREW client) to respond to this dialog box, the server will close the connection. Now after the user response we have to send the feedback to the server (if the connection is not closed). If the connection is closed the client will not open a socket, instead it will display some msg and proceed.[/INDENT]
[INDENT]In this condition we first want to know whether the connection is still alive or closed by the server.[/INDENT]
Regards
Gopal
In such a case you should do one of several things:
(in addition to possibly tweaking your server settings)
1. Keep the connection open until the user responds by
sending your own ping packets to the server every so often.
(Method depends upon your server software and settings).
2. Close the connection upon displaying this dialog box, and
then immediately open up a new connection once the user has
finished entering data.
If it is likely that the user will take some time to respond to the
dialog then you will probably want to go with the second method.
You could also put a time limit on how long the user has to
respond to the dialog box and then perform some action
when the time expires.