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.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
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.)