problem sending image file over the socket in c

后端 未结 2 1610
梦谈多话
梦谈多话 2020-12-20 08:42

I am writing a C based server supporting HTTP. &buffer[5] has the file name. I set the header in next step and then send the file in block of 8Kb. It is working fine whe

2条回答
  •  轮回少年
    2020-12-20 09:30

    If your code is working for txt files, give fread/fwrite a try instead of read/write . There might be a problem with NULL characters in jpg image which are not present in txt files. And do include a content length in header otherwise in some cases your browser will keep on requesting even if your download has finished. In simple words browser don't know when to stop.

提交回复
热议问题