V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
simple2025
0D
V2EX  ›  Linux

关于 lsof -i 的问题

  •  
  •   simple2025 · Oct 21, 2017 · 3107 views
    This topic created in 3124 days ago, the information mentioned may be changed or developed.

    我有一个进程要使用 9877 端口,
    在关闭进程再启动进程的时候,我经常会遇到这种情况
    bind error: address already in use
    但是使用 lsof -i :9877,却没有找到对应的进程
    要等一分钟到两分钟左右 ,才可以重新启动进程,
    就好像有延时一样
    这是什么问题?有什么办法能够解决这种 bind error: address alreay in use,而不是只能靠等吗?

    5 replies    2017-10-21 12:48:09 +08:00
    vcfvct
        1
    vcfvct  
       Oct 21, 2017 via Android   ❤️ 1
    加 sudo 试试,我机器上的 McAfee 的 8081port 就是需要 sudo lsof 才能出来!
    simple2025
        2
    simple2025  
    OP
       Oct 21, 2017
    @vcfvct 我等下试下
    simple2025
        3
    simple2025  
    OP
       Oct 21, 2017
    @vcfvct 我这边要使用 "netstat -anp | grep 9877"才出来,可能是因为处于 TIME_WAIT 状态的原因
    iwtbauh
        4
    iwtbauh  
       Oct 21, 2017 via Android   ❤️ 1
    @chenqh 恩,我记得是让服务器程序使用 setsockopt(2) 系统调用开启 SO_REUSEADDR 选项即可解决
    如果程序没有相应开关必须修改源代码重新编译
    mogging
        5
    mogging  
       Oct 21, 2017 via iPhone
    @chenqh 涨姿势
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6169 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 679ms · UTC 02:38 · PVG 10:38 · LAX 19:38 · JFK 22:38
    ♥ Do have faith in what you're doing.