我使用的是一个,它将TCP端口号port作为强制参数。现在,如何确保为指定一个未使用的端口(我的进程是服务器)?此外,在客户端进程连接之前,socketConnection(..., server = T)正在阻塞。但是客户端进程不知道要连接到哪个端口,因为服务器进程被阻塞了,并且无法确定它所分配的端口号。
当我试图在端口8080上运行一个服务(RavenDB)时,它会停止,而Windows日志显示了以下错误:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: Failed to listen on prefix 'http://+:8080/' because it conflicts with an existing registration