I write socket client-server connection. Server listens client name and if it's not avaible, server closes connection. With correct names all works. Client:
clientSocket = new Socket("192.168.1.102", 15780);
outToServer = new DataOutputStream(clientSocket.getOutputStream());
sendRequest(uName);
currentInt = 0;
updateUI();
Then I check, whether it is possible to open connection.
private void updateUI()
{
if(currentInt <= 100)
{
if(clientSocket.isConnected())
{
outServ.setText("Complete!");
Intent i = new Intent(this, RoomClass.class);
startActivity(i);
mRedrawHandler.removeMessages(0);
}
}else{
currentInt++;
mRedrawHandler.sleep(50);
}
}
And it always is connected! But server-side closed cliet port. I heard that thus it is impossible to check up, whether connection is closed. How to make it?