---
title: "Wiz107sr udp 관련 문의"
url: "https://maker.wiznet.io/forum/10394"
markdown_url: "https://maker.wiznet.io/forum/10394/md"
type: "Forum topic"
category: "Serial-to-Ethernet & ConfigTool"
author: "parkcom167"
created: "2014-07-23T01:35:44+09:00"
last_activity: "2017-05-04T08:33:26+09:00"
language: "ko"
views: 500
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Wiz107sr udp 관련 문의

## Question

Asked by parkcom167 on 2014-07-23 in Serial-to-Ethernet & ConfigTool.

“WIZ107SR UDP 통신이 되지 않습니다.” 라는 질문을 남겼던 사람입니다~

UDP 소스코드를 첨부하면 살펴봐주신다고 하셔서

main.c 파일과 UDP가 동작하는 lookback.c 파일을 첨부하였습니다.

확인부탁드리겠습니다.
[main.c](https://maker.wiznet.io/uploads/short-url/hYwmuctp07BhAxmSD3g67KcMX4c) (4.97 KB)
[loopback.c](https://maker.wiznet.io/uploads/short-url/3U4dLRhhoCcqD9rQFWcX2tQsokF) (3.92 KB)

## Replies

### Reply 1 by irina, 2014-07-23

코드 잘 보았습니다.
TCP Loopback 코드를 기반으로 수정하시는 과정에서 불필요한 동작들이 삽입되어 있는 것으로 보입니다.

UDP Loopback test 코드는 다음과 같이 구성되면 충분합니다.
참고를 위해 W7100A Application note - UDP의 코드 일부를 첨부합니다.

```
void loopback_udp(SOCKET s, uint16 port, uint8 xdata * data_buf, uint16 mode)
{
	uint16 xdata len;
	uint8 xdata destip[4];
	uint16 xdata destport;
	
	switch(IINCHIP_READ(Sn_SR(s)))
	{
		case SOCK_UDP:
			// Check the size of received data
			if((len=getSn_RX_RSR(s)) > 0)
			{
				// Receive data from destination
				len = recvfrom(s,data_buf,len,(uint8*)destip,&destport);  
				
				// Send the data to the destination
				if(len != sendto(s,data_buf,len,(uint8*)destip,destport))
				{
					printf("Sendto Failed\r\n");
				}		
			}
			break;
		        
		case SOCK_CLOSED:                              
			close(s);                                       // Close the SOCKET
			socket(s,Sn_MR_UDP,port,mode);                  // Open the SOCKET with UDP mode
			printf("LOOPBACK_UDPStarted. CH : %bu\r\n",s);
			break;
		
		default:
			break;
	}
}
```

---

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