NoName
NoName

Reputation: 113

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!

Upvotes: 5

Views: 3282

Answers (1)

Milan
Milan

Reputation: 15849

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.

Upvotes: 8

Related Questions