阅读背景:

socket 读、写字节流数据

来源:互联网 

socket是网络通信套接字。主要体现在读与写方面。 ( 阻塞读)

C版本:

int ReadFile(int nFile, void * pData, int * pSize)
{
	int nLeft, nRead;
	char *pcData = pData;
	ASSERT(pData != NULL && pSize != NULL);
	nLeft = *pSize;
	while (nLeft > 0)
	{
		if ((nRead = read(nFile, pcData, nLeft)) < 0)
		{
			if (errno != EINTR)
				ASSERT(0);
			nRead = 0;
		}
		else if (nRead == 0)
			break;
		nLeft -= nRead;
		pcData += nRead;
	}
	*pSize = *pSize - nLeft;
	return 0;
}i



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: