---
title: "Disconnect-reconnect with w5x00_tcp_client_over_ssl"
url: "https://maker.wiznet.io/forum/14695"
markdown_url: "https://maker.wiznet.io/forum/14695/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Gxxx"
created: "2022-10-31T13:58:11+09:00"
last_activity: "2022-10-31T13:58:11+09:00"
language: "en"
views: 309
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Disconnect-reconnect with w5x00_tcp_client_over_ssl

## Question

Asked by Gxxx on 2022-10-31 in Ethernet Chips.

Hi,
I need to connect the w5500 always with the same server and I send it a post request.
When I run the code I notice this:
If I send multiple requests with time intervals &lt; 5 sec the server responds and the socket satus is in SOCK_ESTABLISHED if the time interval is > 5 sec the socket status is SOCK_CLOSE_WAIT.
My question is:

1. Can I avoid the SOCK_CLOSE_WAIT?
   2)If I can’t avoid this, How can I disconnect and reconnect using the same port 443?
   I do:
   disconnect(sock_num)
   socket(sock_num,Sn_MR_TCP, 443,SF_TCP_NODELAY );
   connect(sock_num, target_ip,443);
   but I can’t reconnect.

2. The code takes a long time to execute:
   mbedtls_ssl_handshake
   in the state: MBEDTLS_SSL_CLIENT_KEY_EXCHANGE
   If I need to connect at the same server can I do the mbedtls_ssl_handshake only the first one? How can I do thies?
   Thanks in advance.

---

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