forked from srieger/verteilte-systeme-bsc-ai-examples
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.
28 lines
869 B
28 lines
869 B
/* 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
|
|
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());
|
|
|
|
clientSentence = inFromClient.readLine();
|
|
capitalizedSentence = clientSentence.toUpperCase() + '\n';
|
|
outToClient.writeBytes(capitalizedSentence);
|
|
}
|
|
}
|
|
}
|