sree <sr**************@gmail.com> wrote:
i am doing project a simple http server. it is being writen in
c using sockets. so when there is a request to read a jpeg or any other
file icant do it. my code is working only for html and txt fils. Is
there seperate way to open jpegs etc and buffer them and send them.
In principle there should be no problem in opening, reading or
writing jpeg (or other non-text) files. The only thing you may
have to be careful about is to open the file in binary mode in-
stead of the default text mode, e.g. to open the file for rea-
ding use
FILE *fp = fopen( "myfile.jpeg", "rb" );
since otherwise on some platforms "\r\n" combinations might not
get read in in the way you need it.
And, of course using text oriented functions like fscanf() or
fprintf() etc. doesn't make sense with these files, use fread()
and fwrite(). If that shouldn't help you solve your problem you
should post the relevant part of your code since it otherwise
is impossible to guess what might be going wrong. But keep out
stuff about sockets since that is too much dependent on the
platform you're using and not part of the C language, so you
better ask about that in a newsgroup that is for discussions
about programming on your platform.
Regards, Jens
--
\ Jens Thoms Toerring ___
Je***********@physik.fu-berlin.de
\__________________________
http://www.toerring.de