You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
/* Angelehnt an Kurose/Ross Computernetzwerke (bis 5e Java, ab 6e Python) */
package verteiltesysteme.socket.simple;
import java.io.*; import java.net.*;
class TCPServer { public static void main(String argv[]) throws Exception { int tcpPort = 36037; String clientSentence; String capitalizedSentence;
// Server-Socket erzeugen
@SuppressWarnings("resource") ServerSocket welcomeSocket = new ServerSocket(tcpPort); while (true) { Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
// Try/Catch hinzugef�gt, nachdem bei Einsatz Amazon AWS (Healthcheck des ELB) clientSentence null war
try { clientSentence = inFromClient.readLine(); if (clientSentence != null) { capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } } catch (IOException ioe) { ioe.printStackTrace(); } connectionSocket.close(); } } }
|