Find the answer to your Linux question:
Results 1 to 4 of 4
I have a C++ program that uses unix domain socket in this way: Client A has a socket connection to Server B. A sends some data to B. B processes ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    20

    How to write a timer to monitor a socket server?


    I have a C++ program that uses unix domain socket in this way: Client A has a socket connection to Server B. A sends some data to B. B processes data and return results to A.

    However, sometimes, B might take too long to process data and in such a case, for efficiency consideration, A would expect B to simply terminate the processing and notify A with a failure message other than waiting for ever. So, in B, I would like to write a timer T. It starts timing when B receives data from A. It would timeout if B spends some predefined length of time on processing the data. Then B will stop and sends some message back to A to let it know.

    Any idea or suggestions for doing this? Thanks!

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    Use select() call and FD_SETs for this.
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    Quote Originally Posted by cyberinstru
    Use select() call and FD_SETs for this.
    If the server knows when to terminate the connection and there is a protocol for the communication, it could simply send a TERMINATE request/response (depending on how you look at it) to the client - which the client can honor by closing the socket. You don't need select() - however that is also an option if the server decides to terminate the connection without notifying the client.

    @licht,
    You already know what you want! So, what sort of help are you looking from us?
    The Unforgiven
    Registered Linux User #358564

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    You can check if you have rcvd data to any descriptor using FD_ISSET.... so based on that u can proceed... or else, how do u know, if you r rvng data or not...

    May be i am not aware of the other way around to know that... cud u plz brief the_unforgiven?
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •