import java.util.*;
import java.net.*;
import java.io.*;
class Sock{
public static String getFlag(String hostName, Integer port){
byte[] data = new byte[20];
try{
Socket socket = new Socket(hostName, port);
socket.getInputStream().read(data, 0, 20); //0 to indeks gdzie zaczynay,
socket.close();
}
catch(IOException e){
System.out.println(e);
}
return new String(data, 0, 20);
}
}
class Main
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Integer port = scan.nextInt();
System.out.println(Sock.getFlag("127.0.0.1", port)); //wyprintuje SUCCESS
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter