You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In many situations, it's useful to be able to identify a "free" TCP port, i.e. a port that we can bind to.
CORRECTION +30 min: serverSocket() would only validate that we can listen to the port. To assert we can bind to it, we would have to do more. I need ☕
In R (>= 4.0.0), we can almost use serverSocket(0) for this. It will open a servsockconn connection on a random TCP port assigned to us by the operating system. This works on Linux, macOS, and MS Windows. For example,
However, this is currently a useless connection, because we do not know which port is used here.
Wish
Add a function to query the port of a servsockconn connection, e.g. port(con).
This would make it possible to use the above servsockconn connection as-is, but it would also make it possible to find a random available TCP port, e.g.
The text was updated successfully, but these errors were encountered:
HenrikBengtsson
changed the title
WISH: Find a TCP port that can be bound ("opened") + make serverSocket(0) useful
WISH: Make serverSocket(0) useful (+ find a random TCP port that can be listened to)
Jan 5, 2024
In many situations, it's useful to be able to identify a "free" TCP port, i.e. a port that we can bind to.
CORRECTION +30 min:
serverSocket()
would only validate that we can listen to the port. To assert we can bind to it, we would have to do more. I need ☕In R (>= 4.0.0), we can almost use
serverSocket(0)
for this. It will open aservsockconn
connection on a random TCP port assigned to us by the operating system. This works on Linux, macOS, and MS Windows. For example,However, this is currently a useless connection, because we do not know which port is used here.
Wish
servsockconn
connection, e.g.port(con)
.This would make it possible to use the above
servsockconn
connection as-is, but it would also make it possible to find a random available TCP port, e.g.References
cc/ @noamross
The text was updated successfully, but these errors were encountered: