Re: Socket C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith Thompson

    Re: Socket C

    Richard Heathfield <rjh@see.sig.in validwrites:
    Thiago Dantas said:
    [...]
    >char msg[] = "Hello!\n";
    >send(socketDes criptor, msg, strlen(msg), 0);
    >
    Endianness doesn't really apply to chars.
    >
    Since you're not sending the terminating null character, how will the
    receiver know where the string stops?
    [...]

    Perhaps by seeing the '\n'.

    You wouldn't write the trailing '\0' to a text file; it's plausible
    that you wouldn't want to write it to a socket either. But of course
    it depends on the protocol.

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
Working...