socket programming 
Author Message
 socket programming

Hello

I've a sync and a async IPconnection. How do I test if the connection is
still available?
Currently for the sync connection I catch the puts and gets functions. If an
error occures, I close the connection (catch again) and open it again.
Q1) Is this the right way to do it or is there a better way
Q2) I assume that this will not work for the async connection as the
readable file-event will not be triggered (did not try it yet). What is the
proper way in this case?

WimS



Sat, 08 Mar 2003 03:00:00 GMT  
 socket programming

Quote:

> I've a sync and a async IPconnection. How do I test if the connection is
> still available?
> Currently for the sync connection I catch the puts and gets functions. If an
> error occures, I close the connection (catch again) and open it again.
> Q1) Is this the right way to do it or is there a better way

It sounds reasonable to me.

Quote:
> Q2) I assume that this will not work for the async connection as the
> readable file-event will not be triggered (did not try it yet). What is the
> proper way in this case?

No, the same method will not work because the puts/gets will immediately
return without having done anything.  The right way is to use fileevent.
When the connection closes the readable event will be invoked with the
channel in an eof state.  Your event handler must test for this state
and close the channel *before the handler exits*.  That last bit is
important, otherwise you'll go into an infinite loop.

HTHs,
Steve Ball

--
Steve Ball            |   Swish XML Editor    | Training & Seminars
Zveno Pty Ltd         |   Web Tcl Complete    |      XML XSL
http://www.zveno.com/ |    TclXML TclDOM      | Tcl, Web Development

Ph. +61 2 6242 4099   | Mobile (0413) 594 462 | Fax +61 2 6242 4099



Sun, 09 Mar 2003 04:48:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. socket programming in Smalltalk

2. Low-level socket programming

3. Examples of Socket programming needed

4. Socket programming in smalltalk

5. Socket programming in smalltalk

6. VW 2.5 -- sockets programming, looking for examples, advice

7. Socket programming in VisualWorks 2.0

8. Socket programming in C5

9. Socket programming with VA 3.0a - help!!

10. Using Eiffel for Unix socket programming

11. Socket programming in Dylan

12. Socket Programming question

 

 
Powered by phpBB® Forum Software