@server = TCPServer.open(@host, @port)
rescue Exception => e
@log.fatal("SSH protocol start ... failed. (#{e.to_s})")
raise "SSHServer start failed."
end
@log.info("SSH protocol start ... ok\n")
@protocol_started = true
while @server
@socket = nil
begin
Timeout::timeout(@timelimit) do
@socket = @server.accept
p @socket.class.to_s
p @socket.peeraddr #获得远程主机IP地址等信息,返回值为数组
p @socket.addr #本机ip等信息,返回值为数组
tcpsocket获得远程主机ip信息
最新推荐文章于 2024-06-27 17:09:40 发布
本文详细介绍了SSH服务器的启动流程,包括TCP服务器的初始化、异常处理机制及日志记录方式。此外,还提供了如何获取客户端与服务器IP地址的方法。
1178

被折叠的 条评论
为什么被折叠?



