Hello, I want to print the response given by a Web server using socket primitives (not an HTTP library). I managed to produce the following working code running in the factor Workspace.
USING: io.sockets io.encodings.ascii ; "www.google.com" 80 <inet> ascii [ "GET / HTTP/1.0\r\n\r\n" write flush [ readln dup ] [ ] [ drop ] produce ] with-client [ . ] each But if I prefer to print the HTTP reponse directly in the quotation used by with-client instead of returning a result and then printing it with "[ . ] each", what should I do ? Indeed the default input and output streams are rebound by with-client and thus inside the quotation I do not have access to stdout (the output stream to the console). It took me some time to realize this and have a working code. I thought of getting access to the output stream stored in the global namespace but it doesn't work (\ output- stream get-global). In fact that doesn't make sense maybe. I also thought of using with-output-stream but I can't see how to place it in the code since I need two different output-streams at the same time. Also, if you have any comment, insight or remark about the code, please let me know. Thank in advance, Ludovic Kuty OUTPUT: "HTTP/1.0 302 Found" "Location: http://www.google.be/" "Cache-Control: private" "Content-Type: text/html; charset=UTF-8" "Set-Cookie: PREF =ID=db53d028f07bf514:TM=1231675166:LM=1231675166:S=x-4Mym8gM1pvKy6Y; expires=Tue, 11-Jan-2011 11:59:26 GMT; path=/; domain=.google.com" "Date: Sun, 11 Jan 2009 11:59:26 GMT" "Server: gws" "Content-Length: 218" "" "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/ html;charset=utf-8\">" "<TITLE>302 Moved</TITLE></HEAD><BODY>" "<H1>302 Moved</H1>" "The document has moved" "<A HREF=\"http://www.google.be/\">here</A>." "</BODY></HTML>" ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk