|
The select() API is how you do "time-outs" on a socket. You use select() to wait for data to arrive. If it doesn't arrive within your time-out period, then you simply don't call recv(). The same technique can be used with send(). If you want to be absolutely sure that your program won't ever get "hung up" on the recv() or send() (or, for that matter on connect() or accept()) use non-blocking sockets. Here's a sample from the archives of using select() with recv(): http://archive.midrange.com/rpg400-l/200112/msg00539.html One of these days I'll get around to explaining this better in the tutorial (I've been asked this question many times) but alas I never seem to have the time... On Wed, 29 May 2002, Mike Silvers wrote: > I am creating a socket, connecting to the socket, and sending data over the > socket to a Java socketserver. I have a problem that if the socketserver > ends during the transmission, the RPG program continues to run as if it is > still connected to the socket. I reviewed the "Best Socket Tutorial On The > Web" (you know, Scott Klement's tutorial) and couldn't find anything as far > as timeouts. Does anyone have any suggestions? > > Thanks... > > Mike >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.