From: "ZHOU Xiaobo" <xb.zhou@qq.com>
To: "Huajun Li" <huajun.li.lee@gmail.com>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: write() udp socket
Date: Tue, 26 Jul 2011 13:39:33 +0800 [thread overview]
Message-ID: <tencent_7BA0E68E7426BCE073E1835B@qq.com> (raw)
------------------
Sincerely yours
ZHOU Xiaobo
------------------ Original ------------------
From: "Huajun Li"<huajun.li.lee@gmail.com>;
Date: Sun, Jul 24, 2011 04:33 PM
To: "ZHOU Xiaobo"<xb.zhou@qq.com>;
Cc: "netdev"<netdev@vger.kernel.org>;
Subject: Re: write() udp socket
2011/7/23 ZHOU Xiaobo <xb.zhou@qq.com>:
> question No1:
> When I call
> ssize_t write(int fd, const void *buf, size_t count);
>
>
> on a nonblocking UDP socket, is the return value always equal to 'count'?
>
>
I don't think so. The function may be interrupt by signal or return
due to other reason, so the return value only represents the size it
writes successfully to the fd.
UDP is datagram, so I think it guarantees the 'buffer' in 'write()' is entirely sent
like an atomic operate.
> question No2:
> Can I write() a UDP socket in multiple threads without locking?
>
In my opinion, you could. However, the receiver may not get what you expected.
what will happen? I only concern whether the application 'buffer' is sent partially which
is unacceptable.
>
> thanks
>
>
> ------------------
> Sincerely yours
> ZHOU Xiaobo
next reply other threads:[~2011-07-26 5:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 5:39 ZHOU Xiaobo [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-07-26 5:32 write() udp socket ZHOU Xiaobo
2011-07-23 9:29 ZHOU Xiaobo
2011-07-24 8:33 ` Huajun Li
2011-07-25 17:38 ` Rick Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_7BA0E68E7426BCE073E1835B@qq.com \
--to=xb.zhou@qq.com \
--cc=huajun.li.lee@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).