Richard Pump - 2017-03-29

Hello, I'm having trouble creating a TCP-Server-Application in NESSI2.
I've read the section on Extending NESSI2 in the manual and it only covers UDP-Traffic.

So far I've deducted that TCP-Traffic seems to be exclusively handled via events. Following code seems to be correct:

(Annotations ommited)
public class Server extends AbstractIPApplication {
(...)
@Override
public void handleEvent(Event e) {
    if (e instanceof TCPClientSocketCreatedEvent) {
        ISocket sock = ((TCPClientSocketCreatedEvent)e).getSocket();
        sock.readData(20); //Creates TCPEventReadData when done
    }
    if (e instanceof TCPEventReadData) {
        byte[] data = ((TCPEventReadData)e).getData();
    }
    (...)
}
(...)

Now, I do not understand how to associate the TCPEventReadData-events to the corresponding socket, i.e. assing the received data to a certain client which has sent it (without having the client send it's ID).

Could you please show me some Code on how to implement a multi-client-tcp-server in NESSI2? (Maybe add a TCP example to the existing NESSI2-Example-Application would be useful.)