mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
Fix TCP socket finishConnect() exception handling and connection logic
- Fix bug where finishConnect() required multiple calls before throwing exceptions - Fix logic where address resolution didn't immediately attempt connection - After address is resolved, immediately call channel.finishConnect() - Ensures immediate error reporting for failed socket connections - Improves reliability of socket connection error handling
This commit is contained in:
parent
a43004760f
commit
6aa321971e
@ -329,7 +329,9 @@ object InternetCard {
|
|||||||
private def checkConnected() = {
|
private def checkConnected() = {
|
||||||
if (owner.isEmpty) throw new IOException("connection lost")
|
if (owner.isEmpty) throw new IOException("connection lost")
|
||||||
try {
|
try {
|
||||||
if (isAddressResolved) channel.finishConnect()
|
if (isAddressResolved) {
|
||||||
|
channel.finishConnect()
|
||||||
|
}
|
||||||
else if (address.isCancelled) {
|
else if (address.isCancelled) {
|
||||||
// I don't think this can ever happen, Justin Case.
|
// I don't think this can ever happen, Justin Case.
|
||||||
channel.close()
|
channel.close()
|
||||||
@ -341,14 +343,15 @@ object InternetCard {
|
|||||||
case e: ExecutionException => throw e.getCause
|
case e: ExecutionException => throw e.getCause
|
||||||
}
|
}
|
||||||
isAddressResolved = true
|
isAddressResolved = true
|
||||||
false
|
// After address resolution, immediately attempt connection
|
||||||
|
channel.finishConnect()
|
||||||
}
|
}
|
||||||
else false
|
else false
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
case t: Throwable =>
|
case t: Throwable =>
|
||||||
close()
|
close()
|
||||||
false
|
throw t // Propagate exception instead of returning false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user