#BUGFIX by chzeiher
class: Socket class
changed: #getRandomAvailablePortOnHost:
bandaid to have the method working remotely. By essentially picking a port at random :S
--- a/Socket.st Thu Nov 22 15:48:00 2018 +0100
+++ b/Socket.st Tue Nov 27 16:31:23 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
@@ -1423,19 +1425,19 @@
!Socket class methodsFor:'queries'!
getRandomAvailablePortOnHost:aHostnameOrAdress
-"Attempts binding to port 0 on a specified host, thereby getting assigned a random available port which we return. We then release the socket."
-|socket freePort hostAdress|
-aHostnameOrAdress = nil ifTrue: [ hostAdress := '0.0.0.0' ] ifFalse: [ hostAdress := aHostnameOrAdress ].
-socket := Socket newTCP.
-socket bindTo:0 address:hostAdress reuseAddress:true.
- freePort := socket port.
-socket abortAndClose.
-^freePort
-
-
-
-
-
+ "Attempts binding to port 0 on a specified host, thereby getting assigned a random available port which we return. We then release the socket."
+ |socket freePort hostAdress|
+
+ aHostnameOrAdress = nil ifTrue: [ hostAdress := '0.0.0.0' ] ifFalse: [ hostAdress := aHostnameOrAdress ].
+ socket := Socket newTCP.
+ "/ Well this is awkward, since I cant bind this to a remote port and receive a free port there..we spit for luck.
+ socket bindTo:0 address:'0.0.0.0' reuseAddress:true.
+ freePort := socket port.
+ socket abortAndClose.
+ ^freePort
+
+ "Modified: / 27-11-2018 / 15:16:06 / chris"
+ "Modified (comment): / 27-11-2018 / 16:23:45 / chris"
!
peerFromDomain:domain name:peerName port:port