---
title: "W5100 UDP Socket Question"
url: "https://maker.wiznet.io/forum/10403"
markdown_url: "https://maker.wiznet.io/forum/10403/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "ankitmcgill"
created: "2014-07-25T17:27:13+09:00"
last_activity: "2017-05-04T08:33:27+09:00"
language: "en"
views: 1068
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100 UDP Socket Question

## Question

Asked by ankitmcgill on 2014-07-25 in Ethernet Chips.

I recently started using the w5100 ethernet chip, and the ping the ping test went fine. I am able to set the GWR, SUBR, SHAR, SIPR registers and also read them back just fine (to verify they are being set correctly).

I am also able to open up an UDP socket (I am trying to sent a packet to a NTP server on port 123).

However when I write the SnDIPR and SNPORT for socket 0, when I read the back I get all 0’s.

`Reading MR : 0<\r> IP Address : 192.168.0.180<\r> Subnet Mask : 255.255.255.0<\r> Gateway Address : 192.168.0.1<\r> Gateway Address : 48.02.2A.32.00.82<\r> Socket 0 open in UDP @ source port 123<\r> Socket 0 Destination IP: 0.0.0.0<\r> Socket 0 Destination Port : 0.0<\r>`

As per the datasheet, under SnDIPR … “In UDP mode, this register value decided to user’s written value after receiving peer’s ARP response. Before receiving peer’s ARP response, this register has reset value.”

My code is:

[code]//set destination ntp ip address
val[0]=165; val[1]=193; val[2]=126; val[3]=229;
ETHERNET_WRITE(SOCKET_0_BASE + SNDIPR, val, 4);
retval = ETHERNET_READ(SOCKET_0_BASE + SNDIPR, 4);
printf(“Socket 0 Destination IP: %u.%u.%u.%u\r”,retval[0],retval[1],retval[2],retval[3]);

//set destination port
val[0] = 0x00;
val[1] = 0x7B;
ETHERNET_WRITE(SOCKET_0_BASE + SNDPORT, val, 2);
retval = ETHERNET_READ(SOCKET_0_BASE + SNDPORT, 2);
printf(“Socket 0 Destination Port : %u.%u\r”,retval[0],retval[1]);
[/code]

I feel my issue is something to do with this. What I want to understand is how to open a UDP socket and send data to a server on specified ip/port.

Any help is much appreciated ! ![:smiley:](https://emoji.discourse-cdn.com/twitter/smiley.png?v=12)

---

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