For Programmers: Free Programming Magazines  


Home > Archive > Tcl > July 2004 > Working with nonblocking sockets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Working with nonblocking sockets
Michiel

2004-07-28, 9:08 pm

Hi,

I've been trying and trying but can't get things working like i want to.
I'm trying to get my script connected to a FTP server using a
nonblocking and nonbuffered socket. At the moment I use a while
statement to fetch the data from the socket as it comes in. This works
just fine but the problem is that my script simply comes to a dead end
when the server stops sending data. I need some kind of timer which
'sees' that the server does not send any data and then aborts the while
statement.

while { ![eof $site(control_socket)] } {

if { [gets $site(control_socket) buf] < 0 } {
continue
}
puts $buf
}

My question is; how can I tell the while statement to stop if the server
does not send any data? (e.g. [gets $site(control_socket) buf] gives
me -1 for more than 100 milliseconds in a row)

Thank you for you help,

-Michiel
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com