C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Network »

Retrieving TCP connections information


Posted Date: 27 Mar 2007    Resource Type: Code Snippets    Category: Network
Author: Manikandan BalakrishnanMember Level: Gold    
Rating: 1 out of 5Points: 5



TCP is used to establish peer to peer communication between two computers, “TcpConnectionInformation” class is used to display the informations of existing TCP communication. This is very use full to monitor the network status.

Sample Code:


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
//Retriving IP global properties
IPGlobalProperties IPGproperties = IPGlobalProperties.GetIPGlobalProperties();

//Retriving the TCP connections
TcpConnectionInformation[] connections = IPGproperties.GetActiveTcpConnections();

foreach (TcpConnectionInformation tcp in connections)
{
//Displaying TCP connection informations
StringBuilder sb = new StringBuilder();
sb.Append("Local endpoint:\t"+tcp.LocalEndPoint.Address.ToString());
sb.Append("\nRemote endpoint:\t"+ tcp.RemoteEndPoint.Address.ToString());
sb.Append("\nState:\t\t"+ tcp.State.ToString());
MessageBox.Show(sb.ToString(),"TCP connection status");
}

}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Ping remote computer in the network
Previous Resource: Check if a port is open or closed?
Return to Discussion Resource Index
Post New Resource
Category: Network


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use