W5100 recv() 함수 사용방법?

W5100이 메시지를 10byte 수신 후
rLen = recv(s,buf,20);
을 호출하면, rLen 이 20으로 리턴 됩니다.

수신한 메시지 길이만 리턴 받을 수 있나요?

rLen = recv(s,buf,1);
위 처럼 호출하고, 수신한 패킷을 분석하여,
다음 바이트 수신 여부를 결정해야 하나요?

///recv()//////////////////////////////////////////
/**
@brief This function is an application I/F function which is used to receive the data in TCP mode.
It continues to wait for data as much as the application wants to receive.

@return received data size for success else -1.
*/
uint16 recv(SOCKET s, /< socket index */
uint8 * buf, /
< a pointer to copy the data to be received */
uint16 len /**< the data size to be read */
)
{
uint16 ret = 0;
#ifdef DEF_IINCHIP_DBG
PP(“recv()\r\n”);
#endif

if (len > 0)
{
	recv_data_processing(s, buf, len);
	IINCHIP_WRITE(Sn_CR(s), Sn_CR_RECV);

	/* +20071122[chungs]:wait to process the command... */
	while (IINCHIP_READ(Sn_CR(s)))
		;
	/* ------- */
	ret = len;
}
return ret;

}

//////////////////////////////////////////////////

W5100용 recv() 함수 호출 전에
수신크기를 먼저 확인 후 수신 크기보다 같거나 작은 크기로 recv()함수를 호출하셔야 합니다.

사용예입니다.

uint16 len;
len = getSn_RX_RSR(s)
if(len > 0)  recv(s, buf, len);