---
title: "Pico RP2040 event driven C example for TCP server"
url: "https://maker.wiznet.io/forum/14754"
markdown_url: "https://maker.wiznet.io/forum/14754/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Colin Bate"
created: "2022-12-21T16:51:22+09:00"
last_activity: "2023-01-21T17:41:10+09:00"
language: "en"
views: 655
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Pico RP2040 event driven C example for TCP server

## Question

Asked by Colin Bate on 2022-12-21 in Ethernet Chips.

Hi Wiznet team,
I would like to implement an event driven TCP server for your Pico RP2040 board. I have your lwIP loopback example running but its necessary to poll for the connection and data, I am hoping you have an example of an event driver version like the one available for the Pico-W which also uses lwIP.
Thanks

## Replies

### Reply 1 by lawrence, 2022-12-23

Hello, [@Colin_Bate](https://maker.wiznet.io/u/colin_bate)
Thank you for your interest with pico ethernet.
if you look for interrupt handing drive, we currently do not have it.
There is interrupt pin from W5100S and it connected to rp2040. but to be implemented.
Is there reason why you want to use it with Pico-W?

### Reply 2 by Colin Bate, 2022-12-27 (in reply to reply 1)

Hi Lawrence, thanks for your reply, I use the Pico as I have purchased 3 x Pico RP2040 boards as I want to use a LAN connection, not Wifi for a few projects I have.
I have solved my initial problem with being interrupt driven, I used a modified example of the lwIP loopback.c, it still polls but this seems very efficient passing 60 Pkts/second.
I’m now struggling to get the time from a NTP server via UDP using lwIP. Any guidance would be much appreciated (i.e. are there equilivant functions for (udp_sendto… etc.)
BTW: is it possible to mix lwIP with standard WIZnet non lwIP code in the same application?
many thanks \Colin

### Reply 3 by Colin Bate, 2023-01-09

I have been able to successfully implement setting the RTC via a NTP server using:
retVal = udp_sendto(state->ntp_pcb, p, (const ip_addr_t *)&state->ntp_serverIp, NTP_SERVER_PORT);
…and a callback via
udp_recv(state->ntp_pcb, ntp_udp_recv_cb, state);

Thanks

---

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