Skip to content

Instantly share code, notes, and snippets.

@cosminpopescu14
Last active February 26, 2020 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosminpopescu14/a9c5e04aab255811ef4b0d6349f09b34 to your computer and use it in GitHub Desktop.
Save cosminpopescu14/a9c5e04aab255811ef4b0d6349f09b34 to your computer and use it in GitHub Desktop.
static Runnable task = Main::socketPlay;
private static void socketPlay() {
int count = 0;
try (var serverSocket = new ServerSocket(80)){
var socket = serverSocket.accept();
try (var output = new PrintWriter(socket.getOutputStream(), true)) {
while (count <=10) {
output.println(generateRandomStrings());
count++;
}
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
//in main
task.run();
@cosminpopescu14
Copy link
Author

The previous code was wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment