set timeout for Server Connection
This commit is contained in:
parent
a3a86cf913
commit
00fc294396
|
@ -6,6 +6,7 @@ import org.hso.texturesyncclient.model.Sha256
|
|||
import org.hso.texturesyncclient.model.Texture
|
||||
import java.io.*
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.Socket
|
||||
import java.util.*
|
||||
|
||||
|
@ -23,7 +24,11 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
|
|||
val o: DataOutputStream
|
||||
|
||||
if (socket == null || !socket!!.isConnected) {
|
||||
val sock = Socket(address, port)
|
||||
val sock = Socket()
|
||||
sock.soTimeout = 10_000 /*ms*/
|
||||
sock.keepAlive = true
|
||||
sock.connect(InetSocketAddress(address, port), 1_000 /*ms*/)
|
||||
|
||||
i = DataInputStream(BufferedInputStream(sock.getInputStream()))
|
||||
o = DataOutputStream(BufferedOutputStream(sock.getOutputStream()))
|
||||
|
||||
|
|
Loading…
Reference in New Issue