I try to disconnect my client:
public class SiecZapis {
public static Socket gniazdo2;
public static void main(String[] args) {
new SiecZapis().doIt2();
}
public void doIt2() {
try {
ServerSocket gniazdo = new ServerSocket(4242);
while(true) {
Socket gniazdo2 = gniazdo.accept();
PrintWriter pisarz = new PrintWriter(gniazdo2.getOutputStream());
String porada = "test2";
pisarz.println(porada);
pisarz.close();
System.out.println(porada);
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
public void exit() {
gniazdo2.disconnect();
}
}
I tried to use something like socket.disconnect()
from this topic but there is not method disconnect
in socket
.
Could you please advise how to handle this topic?