Ethernet needs to receive one byte to see new connection

Hello there,

I have been searching around a lot and couldn’t find a solution yet.
I want my Arduino to listen on a TCP port for incoming connections.
The server which is asking for data does not send any bytes and just connects.
Whenever a connection is established to the Arduino, it should send a string of measurement data and close the connection.

In all the Telnet examples there is a notice about “just press any key to start the session” which is not possible in my case.
Is there any way I can detect a plain TCP connect?

Tested Hardware:
Arduino Ethernet with 802.1af PoE module
Duemilanove with original Arduino Ethernet shield (first version)

Used Software:
Arduino 1.0

Example Code:

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

EthernetServer server = EthernetServer(23);
EthernetClient client;
static uint8_t mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x67, 0x5E };  

void setup() {

void loop() {
  if (server.available()) {
    client = server.available();

server.available() returns “the first client that has data ready to read”. Maybe you can take the contents of .available() to loop through the existing clients:

void ForEachClient()

    for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
        EthernetClient client(sock);
        if (EthernetClass::_server_port[sock] == _port &&
            (client.status() == SnSR::ESTABLISHED ||
             client.status() == SnSR::CLOSE_WAIT)) {

// client is a currently open client connection to the server on the specified port

For an ftp server, there are at least 2 servers, a command server (port 21) and a data server (port 20 if active mode another if passive mode)

All of the Ethernet routines seem to randomly cycle through all of the possible sockets to find the connection by comparing to the _port, I see a linkage from the calling server callingserver.accept(), callingserver.available(), but in the code provided, there is no server specified so where does that linkage to the correct _port come from? Is it the hard coded one used for server.accept?

I have proposed adding a server.getsocket function to the Ethernetserver code to return its _sock so that a client could connect using client.connect(server.getsocket)… This works. See my post at,93502.15.html