Check out example codes for "android set socket timeout". It will help you in understanding the concepts better.

Code Example 1

// see https://developer.android.com/reference/java/net/Socket#setSoTimeout(int)

try {
  mSocket.setSoTimeout(10*1000);
  // OR
  mSocket.connect(address, 10*1000);
} catch (SocketTimeoutException e) {
  // on timeout
}

Learn ReactJs, React Native from akashmittal.com