Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!panix!panix.com!forkosh From: JohnF Newsgroups: comp.lang.c,comp.programming Subject: Re: [OT] a server http Date: Wed, 13 Apr 2011 11:14:28 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 24 Message-ID: References: <4d7f9ac1$0$1353$4fafbaef@reader2.news.tin.it> NNTP-Posting-Host: panix3.panix.com X-Trace: reader1.panix.com 1302693268 24466 166.84.1.3 (13 Apr 2011 11:14:28 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 13 Apr 2011 11:14:28 +0000 (UTC) User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (NetBSD/5.1 (i386)) Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:2374 comp.programming:223 In comp.lang.c io_x wrote: > why my little http server > is ok for send the right file eg. file.htm > but is not ok in send the file image.gif > > in other words, it can import the file > and not import the gif image in that page. Is it compiled for windows? And are you writing file.htm and image.gif to stdout? I had the same problem with my own little server getting it to run on windows (in addition to linux). And you found the problem yourself mentioning \n in one of your followup posts. In windows, stdout is ascii, not binary. You have to #include and #include , and then issue a _setmode(_fileno(stdout),O_BINARY) to make it binary for windows. Otherwise windows gives you the "newline problem", i.e., every time your gif image happens to contain a byte that's a carriage return, windows will tack on an extra linefeed for you. And that'll totally mess up your gif. -- John Forkosh ( mailto: j@f.com where j=john and f=forkosh )