James wrote: > i'm trying to communicate with a server which sends output down a socket. > The server sends a code and then some text (e.g 01: Connection Refused). > What i'd like to do is just recv the first 2 bytes and act on them, instead > of having to recv the whole line (i don't know how long the lines of text > are, they can be changed), if i do a recv for 2 bytes i'll get '01' > but then the next recv will get the rest of the text won't it? It depends upon the protocol: it will work with TCP, but not UDP (calling read(), recv() etc on a UDP packet will read the requested number of bytes and then discard the rest of the packet). > i could recv 1 byte at a time, storing the characters in a buffer, until a > newline was found (all output from the server ends in \n) but that sounds > overly complicated. Why don't you just use fgets(), fscanf() etc? -- Glynn Clements <[EMAIL PROTECTED]>
