linux下面,可以通过什么函数获取当前网络连接的状态(比如连接、断开等)
答案:2 悬赏:0 手机版
解决时间 2021-02-24 07:09
- 提问者网友:记得曾经
- 2021-02-23 08:15
linux下面,可以通过什么函数获取当前网络连接的状态(比如连接、断开等)
最佳答案
- 五星知识达人网友:轻熟杀无赦
- 2021-02-23 09:55
[root@localhost ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes
[root@localhost ~]#
最后一行 Link detected: yes 说明网线插着。
别用ifconfig命令看,这个命令只对已经配置好的网卡管用,对插上网线但是尚未配置的网卡不一定灵。
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes
[root@localhost ~]#
最后一行 Link detected: yes 说明网线插着。
别用ifconfig命令看,这个命令只对已经配置好的网卡管用,对插上网线但是尚未配置的网卡不一定灵。
全部回答
- 1楼网友:雾月
- 2021-02-23 11:16
linux c中,获取当前进程id 函数为getpid() ;
头文件:#include
函数原型:pid_t getpid(void);
函数说明:getpid ()用来取得目前进程的进程id,许多程序利用取到的此值来建立临时文件, 以避免临时文件相同带来的问题。
返回值:目前进程的进程id
范例
#include
#include
main()
{
printf("pid=%d\n", getpid());
}
执行:
pid=1494
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯