NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: minimum write size of SOCK_STREAM?



Andrew Cagney <andrew.cagney%gmail.com@localhost> writes:

> Sender
>
>         int sock = cloexec_socket(AF_UNIX, SOCK_STREAM, 0);
>         if (sock < 0) { ...
>         }
>         if (connect(sock, (struct sockaddr *)&ctl_addr,
>                     offsetof(struct sockaddr_un, sun_path) +
> strlen(ctl_addr.sun_path)) < 0) { ...
>         }
>         /* Send message */
> #if 0 // NetBSD hack
>         const ssize_t min = 856;
>         if (len < min) {
>                 llog(ERROR_STREAM, logger, "bumping up buffer from %td to %td",
>                      len, min);
>                 len = min;      /* this just writes pat of the string
>                                  * buffer */
>         }
> #endif
>         if (write(sock, msg, len) != len) { ...

There is no reason to expect that read on the peer will return once with
the full message, even though doing so would be typical.

Speculating, the message is small enough that several mbufs are used,
instead of a cluster, and when one is put on the socket, it becomes
readable.


Home | Main Index | Thread Index | Old Index