Click here to Skip to main content
15,906,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hey guys

i need to write a application to catch every outgoing/incoming network connection!

i totally don't know the trick that how to become between host and network area!

is there any specific IP/Port that needs to be listened or any configuration in network conf file or any thing!?

Any help would be appreciate, i just need a clue!

thanks in advance.
Posted
Updated 6-Mar-12 2:26am
v3

If you only want to monitor connections try:

C#
using System.Net.NetworkInformation;
...
var connections = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections();


You'll need to call this periodically to catch new connections.

You could also use WinPCap to capture all network packets and extract source and destination IPs and ports from them.

If you want to control those connections you should use 'Packet Filtering API' available since Win2000. There are few articles here you can use to start:
Packet Filtering in .NET
Simple Packet - Filter Firewall
Developing Firewalls for Windows 2000/XP
 
Share this answer
 
v3
Comments
dariush_ha 6-Mar-12 9:44am    
thanks, i you may to edit your comment because the html tag are not setted right!
looks awful to read!!:-(
sjelen 6-Mar-12 10:01am    
I tried, but editor keeps showing this as plain text :( ...
dariush_ha 6-Mar-12 9:45am    
I need to interact either! for example block some invalid connections or ...
Hi,

Please have a look at my solution, maybe it also works for you. It's not catching packets or something, it's a method to proof if connection is established.

Listener on internet connection established[^]

With Best Regards
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900