简体   繁体   中英

Access to TCP statistics/information per socket possible? (C/C++)

I require some informations like the amount of resend packages/packet-loss occurred for a specific TCP-Socket I created. Does somebody know a way how to access or request such informations directly from my C/C++ program? Maybe something Linux specific?

Or do I need (as a workaround) to capture and analyze my own traffic?

Thanks in advance!

By using getsockopt() to get or setsockopt() to set TCP socket options, you can use TCP_INFO option on linux machines in order to get information about a socket. This option should be avoided if you want the code to be portable.

What you will get back is a struct tcp_info from the kernel that contains information such as retransmissions, lost packets, states etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM