Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #309

Re: socket client thread

From Jasen Betts <jasen@xnet.co.nz>
Newsgroups comp.os.linux.development.apps
Subject Re: socket client thread
Date 2011-12-13 11:46 +0000
Organization Dis (not Dat) Organisation
Message-ID <jc7dtr$gk1$2@reversiblemaps.ath.cx> (permalink)
References <jc5vcg$da4$1@dont-email.me>

Show all headers | View raw


On 2011-12-12, Bill M <wpmccormick@gmail.com> wrote:
> Hello,
>
> I'm working on socket client/server apps where the client app starts the 
> connection on a separate pthread and then sits in a loop to send messages.
>
> The problem I'm having is finding how to kill the client app when the 
> server dies. If I use telnet has the client, he does exit.
>
> So, in pseudo-code ...
>
> start_client() //starts client connection on another thread
>
> while(!quit && connected) {
> 	
>    message = get_user_message
>
>    //this blocks
>    reply = send_message_to_server(message)
>
>    print(reply)
> 		
> }
>
>   ...

> What is the usual method to know the server is still alive?

to test if a thread is alive, send a null signal:

  pthread_kill(client_thread,0);

also if it has died you should also get an error on the socket.

-- 
⚂⚃ 100% natural

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

socket client thread Bill M <wpmccormick@gmail.com> - 2011-12-12 16:31 -0600
  Re: socket client thread David Schwartz <davids@webmaster.com> - 2011-12-12 18:35 -0800
  Re: socket client thread Jasen Betts <jasen@xnet.co.nz> - 2011-12-13 11:46 +0000
    Re: socket client thread Bill M <wpmccormick@just_about_everywhere.com> - 2011-12-13 15:32 -0600

csiph-web