With help from koettermar...@gmx.de who responded to my cry on libcurl mailing list, I think the webserver now works properly. Should be no connection reset problems now. There's a 20 second time limit for receiving acknowledgement from your browser to shut down its transmit end of the connection, and a 2K limit on the size of requests. However the new code shuts down earlier if possible.
http://184.106.135.43:1234/ The current close code looks like: /////////////////// fprint$ cerr,"fthread socket "+str k+" close delay ..\n"; Faio::sleep(clock,DELAY); // give OS time to empty its buffers fprint$ cerr,"fthread socket "+str k+" shutdown now\n"; // try this: // Advised by: koettermar...@gmx.de, MANY THANKS! gen hack_recv: socket_t * &char * int * int -> int = "recv($1,$2,$3,$4)"; var buf:char ^1025; var counter = 0; var extra = 0; shutdown(k,1); // shutdown read retry:> var b = hack_recv(k,C_hack::cast[&char] (&buf),1024,0); //println$ "Error code " + str b + " from read after shutdown"; if b > 0 do extra += b; if extra > 2000 do println$ "Read too many extraneous bytes from OS buffer"; goto force_close; done; goto retry; elif b == -1 do ++counter; if counter > 200 do println "Timeout waiting for write buffers to be flushed"; goto force_close; done; Faio::sleep(clock,0.1); // 100 ms goto retry; done; assert b==0; force_close:> Flx_socket::shutdown(k,2); ioclose(k); fprint$ cerr,"fthread "+str k+" terminating!\n"; /////////////////// There is actually a problem in that Felix streamed sockets always block until eof, error, or request satisfied -- and can't distinguish them. So to read a http GET request of known length reliably is impossible. We can read say 2K bytes, but the read won't return UNLESS the client shuts down their transmitter, it will just hang AFAIK. RF: we need to fix that! We need a timeout. Also we need to tell the difference between EOF and ERROR. That is why the above code uses "hack_revc()", it needs to distinguish the cases -1 (error), 0 (eof) and >=0 (some bytes read). -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Achieve Improved Network Security with IP and DNS Reputation. Defend against bad network traffic, including botnets, malware, phishing sites, and compromised hosts - saving your company time, money, and embarrassment. Learn More! http://p.sf.net/sfu/hpdev2dev-nov _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language