TCP Authentication / Arduino mega2560

Hello,

I'm developing a software that talks with my arduino mega2560 via tcp connection. So far is going ok but i want to implement
authentication before start to send the data to the board.

So I was looking at EthernetServer librarie and I saw that it supports 4 connections at same time. There is any way to manage these 4 connections differently? or at least do some authentication for each connection?

there is any librarie to do that?

Regards,
Everton

Hi

The W5100 ethernet chip provides four sockets which could technically be used for four simultanenous ethernet connections within an Arduino application.

Each EthernetClient object uses say 400 bytes on SRAM within your application if you instantiate it. If you tried to process four EthernetClient sockets all at the same time you will use say 1,600 bytes of SRAM - and you still need to implement code to switch between the connections to process them according to your application design and requirements - likely very complex.

Generally an Arduino application processes each socket connection sequentially. You use EthernetServer.available() to instantiate a waiting connection, fully process it and then call EthernetClient.stop() to close the connection and release its resources. While one socket connection is instantiated the other three act as buffers for additional incoming connections that your application is not yet ready to process.

I use an implementation of session cookies to implement authentication and security controls. The user logs in, the session cookie is created and the user can perform any appropriate web site/page activity that authentication allows. The session cookie passes automatically back and forth between my application and the end-user's browser. The end-user's browser send the session cookie (a random six digit number) back to my application to authenticate each html request.

My application deletes (invalidates) session cookies after about twenty minutes - to continue the user has to log in again.

The full source code to my application is available on its website at http://www.2wg.co.nz/ Have a look in the PUBLIC folder on the application's SD card. Download the readme.txt and follow that - your will want the cookies.txt and latest HA*.ino files.

Cheers

Catweazle NZ