---
title: "WizNet5100 accepts connections on ANY TCP port, even when none are open"
url: "https://maker.wiznet.io/forum/13819"
markdown_url: "https://maker.wiznet.io/forum/13819/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "WhizzBangGone"
created: "2020-05-09T19:10:01+09:00"
last_activity: "2020-05-25T16:08:06+09:00"
language: "en"
views: 771
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# WizNet5100 accepts connections on ANY TCP port, even when none are open

## Question

Asked by WhizzBangGone on 2020-05-09 in Ethernet Chips.

I am using an Arduino shield with W5100 chip. Once I assign a MAC address and IP address and start Ethernet with Ethernet.begin(), the W5100 starts accepting incoming connections. This is before server started on a selected TCP port. Instead of getting an immediate “Connection refused” message, attempting to connect with a terminal (e.g. PuTTY) will result in a terminal window opening and staying open for a couple of minutes or so before eventually timing out. It does not appear possible to send or receive data over the connection but the behavior is unexpected.

Further, if a server is started on a specific TCP port, a client connecting to it will be able to exchange data as expected. However, if the port is then closed, or changed while the terminal is still connected, the connection is not dropped, but remains open although data transfer seems no longer possible.

## Replies

### Reply 1 by irina, 2020-05-11

Could you please post your source code on the website?
Then I’ll check about it.

### Reply 2 by WhizzBangGone, 2020-05-11

This is all you need to replicate the problem (using Arduino IDE):

```
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 4, 44);
IPAddress myDns(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);

//EthernetServer server(8080);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway, subnet);
  Serial.begin(9600);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
  }

}


void loop() {
}
```

You will notice that the EthernetServer line is commented out and there are no open ports. However if you connect to the interface using ANY TCP port number using a terminal program such as e.g. PuTTY, it will open a terminal window instead of rejecting the connection.

The problem has been confirmed by at least one other person. They were able to test with both a W5100 and W5500 and only the W5100 had the problem.

### Reply 3 by irina, 2020-05-25 (in reply to reply 2)

I’m sorry for late reply.
I think we or you need to check the Ethernet library in Arduino IDE.
Because this issue didn’t occur in the io-library code we provide,it is for embedded user.

### Reply 4 by WhizzBangGone, 2020-05-25

Thank you for getting back to me. I did raise the issue on the Arduino Ethernet library GitHub. I did get an acknowledgement from another user who confirmed they had the same problem. It is interesting to note that another library does not behave the same way. I will pass this information back into the GitHub case.

[github.com/arduino-libraries/Ethernet](https://github.com/arduino-libraries/Ethernet/issues/133)

#### [Server not rejecting client connections not destined for the server port](https://github.com/arduino-libraries/Ethernet/issues/133)

opened 11:08AM - 09 May 20 UTC

[![SheetLightning](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/22dbf709aad134ac74096b4b5764dbddb9cb9d61.png) SheetLightning](https://github.com/SheetLightning)

topic: code   type: imperfection

I have started a server with for example in the definitions: `EthernetServer …ethServer(8080);` In void setup(): `ethServer.begin(); ` In the loop I am accepting data from a connected client: ``` EthernetClient ethClient = ethServer.available(); if (ethClient){ if (ethClientConnected){ while (ethClient.available()) { // Read the bytes incoming from the client: char chr = ethClient.read(); // Echo the bytes to serial Serial.write(chr); } } }else{ if (ethClientConnected){ ethClient.stop(); ethClientConnected = false; } } } ``` However, I found that it is also possible to connect with any other TCP port. The client will not accept or receive data on that port and will eventually time out, but the client (PuTTY) is establishing a connection rather than being immediately rejected as might be expected. Tried with both RAW and Telnet options. What is more, if you change port with: `ethServer = EthernetServer(port);` The existing port does not disconnect as might be expected. It no longer processes data, but remains a connected 'zombie' until the client is shut down. Finally, why no server.stop() method? Should it not be possible to not only start, but also to stop a server (as indeed one can with WiFi)?

---

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