Message-ID: <5LgQCh$WLR@newsmth.net>
Subject: socket接收数据的问题
Date: Mon, 20 Jan 2014 07:12:43 +0000
From: fighterstar@newsmth.net-SPAM.no (lovelife)
Path: 74.82.202.154!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-cn.bbs.comp.network.programming.20141003.mbox.gz!border1.nntp.dca.giganews.com!nntp.giganews.com!newsgate.cuhk.edu.hk!news.neu.edu.cn!news.newsmth.net!NEWSMTH
Newsgroups: cn.bbs.comp.network.programming
Organization: 水木社区
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: NetPRG/z/M.1390201963.C0
Lines: 15
Xref: 74.82.202.154 cn.bbs.comp.network.programming:13381

发送方按以下方式发送数据:
send包头(8字节)
send包体(70-100字节)

接收方按以下方式接收数据:
select (由于要接收多个连接的数据,这个select是必要的)
recv包头(8字节)
recv包体(70-100字节)

现在发现,recv包头的操作几乎不耗时(0.00001秒左右),但是recv包体的操作却很耗时(1秒左右)。有没有办法,使得recv包体的操作几乎没有耗时?(select操作耗时没关系)

比如在发送端做某种设置,使得所有的字节一次性传送到接收端?这样recv包体的操作就不耗时了?

--

※ 来源:·水木社区 http://www.newsmth.net·[FROM: 123.127.49.*]