When I handle Ethershield in Arduino, I can't recover from the communication problem?

Asked 2 years ago, Updated 2 years ago, 138 views

It's not an Arduino-specific issue, it's because I don't know much about TCP/IP, so the solution is at a standstill.

I use boards such as W5100 and enc28j60, which are compatible with Ethershield, but sometimes there seems to be a problem with the communication, so I can't write the code for the problem.

As a countermeasure, I restart with watchdog, but there is a failure.The reason seems to be that it should not be listed on the router's client list and should be left for about 5 minutes before rebooting.

·Throw a get request with arduino, http
·Reboot with watchdog timer after 8 seconds without completing request processing
·Frequent stops for about 3 hours, 1 day, and several weeks

Typically, reboots continue until successful, so for example, if there is a problem on the router side, it usually recovers, but sometimes it doesn't work, and Arduino's power cycle doesn't.

The buffalo router connects to the Internet in a common configuration with optical circuits, but it does not accept reconnections while the name is in the client list in the router administration screen.

After waiting for about 5 minutes, it disappears from the list and connects as if nothing had happened, but I wonder if there is a way to overwrite the cache or shorten the expiration date of the cache.

In my own experience, even with wired connections, Windows terminals can communicate immediately by disconnecting and reconnecting on the OS.The correct procedure for disconnecting TCP/IP is not followed and it appears to have failed on reconnecting.

In order to reproduce on Arduino, I would like to ask if there is anyone who can give me tips on what to start with.Is there a way to perform the reset operation in a sketch?

tcp arduino

2022-09-29 21:26

1 Answers

Assume that bind() to the same TCP/IP port fails.

Due to the influence of 2ML due to TIME_WAIT from the active close (self close first) You cannot bind() to the same port for 120 seconds.

As a countermeasure, using the SO_REUSEADDR option
on the same port You can bind().Simply put, bind() will succeed even if you don't have it again for 120 seconds.

Another solution is
if you specify the port number specified in bind() as "0" TCP protocol-side configures a random port.
This means that ports in the TIME_WAIT state can be avoided, so bind() will not fail.

However, since you don't have to bind() to port 0, I think you will be able to connect using the following steps.

■ TCP Client Connection Steps
1. socket()
2.connect()
ランダム TCP connection via random port (no bind is required for clients)


2022-09-29 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.