Jump to content
Sign in to follow this  
tm4c

EthernetServer Does not accept new clients after Some Time

Recommended Posts

I have TM4C129XL board and i prepared an Energia sketch and debugging it on Code Composer Studio. I'm using ethernet server and a client is making requests in approximately every 2 seconds. After server sends response to client i'm calling client.stop() method. This is working fine but after apprx. 3 or 4 days ethernet server just stops accepting new clients.

When i debug the code i saw that in EthernetServer.cpp => do_accept() function

	for (i = 0; i < MAX_CLIENTS; i++) {
		if (server->clients[i].port == 0)
			break;
	}
	if (i >= MAX_CLIENTS) {
		return ERR_MEM;
	}

It doesnt find a client with it's port set to '0'. It returns ERR_MEM. 

I don't understand why this is happening. Because as i said when ethernet server accepts a new client and sends it's response i immediately call client.stop() function. (MAX_CLIENTS = 8)

My simplified code:

loop()
{
delay(200);
  client = server.available();
  delay(100);
  if (client)
  {
    if (client.available() > 0)
    {
      ...

      for(i =0;i<MaxpacketLength;i++)
      {

        if (!client.connected())
        {
          break;
        }

        receiveByte = client.read();

        //It adds bytes received to a buffer here. After it finds a specific command it sends a response to client here.
              break;
      }
      client.stop();
    }
  }
}

 

Share this post


Link to post
Share on other sites

How can i edit ethernetserver library for :

In Do:accept function, if there is no free clients, i want to disconnect all clients and accept this new client? I tried myself but i'm getting faultISR.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...