kerryjiang / SuperSocket

SuperSocket is a light weight, cross platform and extensible socket server application framework.
Apache License 2.0
3.95k stars 1.15k forks source link

服务器启动失败,端口占用如何获取异常 #741

Closed hailiangchen closed 2 months ago

hailiangchen commented 3 months ago

当端口占用的时候,服务器启动失败的信息,如何获取

kerryjiang commented 3 months ago

Logs里面没有信息吗?

hailiangchen commented 3 months ago

调试日志中有启动失败的信息。我想的是在调用start/run的时候,如果出现端口占用,服务启动不起来,这个时候能报个错误或者返回个false,我能知道服务启动失败了;

kerryjiang commented 3 months ago

You can access server state:

https://github.com/kerryjiang/SuperSocket/blob/90d26c24de3816416361aa3d9320d6019c74824f/src/SuperSocket.Server.Abstractions/IServerInfo.cs#L17

kerryjiang commented 3 months ago

Or like this: https://github.com/kerryjiang/SuperSocket/blob/90d26c24de3816416361aa3d9320d6019c74824f/test/SuperSocket.Tests/MainTest.cs#L55

hailiangchen commented 2 months ago

嗯嗯,目前是通过State 判断的