public static void main(String[] args)
{
new Thread(new Runnable()
{
@Override
public void run()
{
try (ServerSocket socket = new ServerSocket(1234))
{
Socket accept = socket.accept();
accept.setSoTimeout(100);
int read = accept.getInputStream().read();
System.out.println(read);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}).start();
new Thread(new Runnable()
{
@Override
public void run()
{
try (Socket socket = new Socket("localhost", 1234))
{
Thread.sleep(1000);
}
catch (UnknownHostException | InterruptedException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}).start();
}