Hello!
Im only a hobbyer with Java, no computer schools at all.
is this code about everything i need to go studying the best way to do a server with multiple clients.
while(true)
{
Socket incoming = s.accept();
Runnable r = new ThreadedHandler(incoming);
Thread t = new Thread(r);
t.start();
}
class ThreadedHandler implements Runnable
{
...
public void run(){
try{
InputStream inStream = incoming.getInputStream();
OutputStream outStream = incoming.getOuputStream();
// process input and send response
incoming.close()
}
catch(IOException e){
}
}
}
question -> should it the next line rather be like ->
class ThreadedHandler ( Socket incoming ) implements Runnable
I then only need to inStream.read() and outStream.write() ??
I still need an very basic skeleton for NIO client, no extras, just very basics,
Port, IP, Socket, what else ??
//----
Thanks,