# TCP 4.0.0 Endpoint Problem

**URL:** <https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187>\
**Category:** Libraries\
**Created:** [September 12, 2023, 6:50am UTC](https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187 "2023-09-12T06:50:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![emrecntz](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/emrecntz/32/3066_2.png) [@emrecntz](https://forums.freertos.org/u/emrecntz)\
**Post date:** [September 12, 2023, 6:50am UTC](https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187/1 "2023-09-12T06:50:44Z")

</div>

Hi,

I work with TCP 4.0.0 Zynq port. I want to get endpoint from given ip address. I used FreeRTOS\_FindEndPointOnIP\_IPv4() function but it is not working because pxEndPoint-\>ipv4\_settings.ulIPAddress is always 0 and this function returns first endpoint. In FreeRTOS\_FillEndpoint() function, there is a comment that “The field ipv4\_settings.ulIPAddress will be set later on”. How can I set this value and how can I get endpoint from ip address?

Thanks.

---

<div class="post-metadata">

**Author:** ![moninom1](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/moninom1/32/4343_2.png) [@moninom1](https://forums.freertos.org/u/moninom1)\
**Post date:** [September 12, 2023, 10:29am UTC](https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187/2 "2023-09-12T10:29:41Z")

</div>

HI @emrecntz

Thank you for your post.

> [@emrecntz](#):
>
> pxEndPoint-\>ipv4\_settings.ulIPAddress is always 0 and this function returns first endpoint. In FreeRTOS\_FillEndpoint() function, there is a comment that “The field ipv4\_settings.ulIPAddress will be set later on”

When we initialise the endpoint with FreeRTOS\_FillEndPoint, it only updates ipv4\_defaults.ulIPAddress and when network down event is called the defaults endpoint values will be copied back to ipv4\_settings values [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/source/FreeRTOS_IP_Utils.c#L920):

```auto
( void ) memcpy( &( pxEndPoint->ipv6_settings ), &( pxEndPoint->ipv6_defaults ), sizeof( pxEndPoint->ipv6_settings ) );

```

Can you please share how are you initialising the endpoints?  
Here is an example of adding Endpoints correctly : [IPv6\_Multi\_WinSim\_demo](https://www.freertos.org/embeddedtcp.html#IPv6WinSIMDemo)

Please let us know if this helps.

---

<div class="post-metadata">

**Author:** ![emrecntz](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/emrecntz/32/3066_2.png) [@emrecntz](https://forums.freertos.org/u/emrecntz)\
**Post date:** [September 12, 2023, 10:49am UTC](https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187/3 "2023-09-12T10:49:58Z")

</div>

Hi @moninom1,

I understand my mistake after your explanation. I had called FreeRTOS\_FindEndPointOnIP\_IPv4() function before network down event because of this reason I could not update ipv4\_settings values. When I called FreeRTOS\_FindEndPointOnIP\_IPv4() function after network down event, my problem is solved.

Thank you.

---

<div class="post-metadata">

**Author:** ![moninom1](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/moninom1/32/4343_2.png) [@moninom1](https://forums.freertos.org/u/moninom1)\
**Post date:** [September 13, 2023, 5:16pm UTC](https://forums.freertos.org/t/tcp-4-0-0-endpoint-problem/18187/4 "2023-09-13T17:16:06Z")

</div>

Glad it worked. Thank you for reporting back.
