Send HTTP response using C socket

前端 未结 1 1782
清歌不尽
清歌不尽 2021-01-01 06:32

I`m trying to send HTTP response to browser

char *reply = 
\"HTTP/1.1 200 OK\\n\"
\"Date: Thu, 19 Feb 2009 12:27:04 GMT\\n\"
\"Server: Apache/2.2.3\\n\"
\"La         


        
相关标签:
1条回答
  • 2021-01-01 06:38

    sizeof(reply) evaluates to the size of a char *, aka size of a pointer. Use strlen.

    send(client, reply, strlen(reply), 0);
    
    0 讨论(0)
提交回复
热议问题