---
title: "W5100 recv() 함수 사용방법?"
url: "https://maker.wiznet.io/forum/10549"
markdown_url: "https://maker.wiznet.io/forum/10549/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "timedoit0"
created: "2014-09-25T08:50:49+09:00"
last_activity: "2017-05-04T08:33:55+09:00"
language: "en"
views: 552
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100 recv() 함수 사용방법?

## Question

Asked by timedoit0 on 2014-09-25 in Ethernet Chips.

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, /**&lt; socket index */
uint8 * buf, /**&lt; a pointer to copy the data to be received */
uint16 len /**&lt; 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;
```

}

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

---

Source: https://maker.wiznet.io/forum/10549
