1
I made a socket in C. This program is command-line operated and compiled over Linux. It takes as parameter a complete URI and a file name, and then connects to the server, retrieves the page and saves it in the informed file.
After obtaining the remote data. The file received by the function recv comes with a HEADER.
The question is: How to remove this HEADER before the file is written by the fwrite function().
It didn’t work, I’m trying to do it with a state machine, byte by byte. Sorry ignorance, but nas I am able to post my code formatted here in this post.
– Mazy999
creates the states
HEADER0
,HEADER1
,HEADER2
, andHEADER3
. When you’re inHEADER0
and receive a'\r'
becomes a stateHEADER1
; otherwise remains in stadiumHEADER0
; if you’re in a stateHEADER1
and you get'\n'
passes toHEADER2
; or else go back toHEADER0
; when state isHEADER2
and you get'\r'
passes toHEADER3
; when state isHEADER3
and you get'\n'
that'\n'
is the last byte of the header.– pmg