C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get Transport Control Protocol Information
WhatsApp
Kailash Chandra Behera
12y
3.4
k
0
0
25
Blog
Code To get transport control protocol information.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Net.NetworkInformation;
using
System.Net;
namespace
Network
{
public
class
TcpConnectionInfo
{
public
string
GetNetworkInformation()
{
System.Text.
StringBuilder
strBldr =
new
System.Text.
StringBuilder
();
try
{
strBldr.Append(
"Current IP Connections:"
+
Environment
.NewLine);
foreach
(
TcpConnectionInformation
tcpConnection
in
IPGlobalProperties
.GetIPGlobalProperties().GetActiveTcpConnections())
{
strBldr.Append(
""
+
"\t"
+
" Connection Info:"
+
Environment
.NewLine);
strBldr.Append(
""
+
"\t"
+
""
+
"\t"
+
" Remote Address: "
+ tcpConnection.RemoteEndPoint.Address.ToString() +
Environment
.NewLine);
strBldr.Append(
""
+
"\t"
+
""
+
"\t"
+
" State: "
.PadRight(17) + tcpConnection.State.ToString() +
Environment
.NewLine);
}
}
catch
{
}
return
strBldr.ToString();
}
}
}
People also reading
Membership not found