473,766 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TCP/IP Monitoring in .NET

Does anyone have a code sample of how one would "listen"
to a TCP/IP session between an application on the local
machine and a remote host.

I'm looking for code that would allow me to specify a
local IP and a local port which is already in use by
another application (outside of my control) and simply
watch the traffic.

I know there are open source packet analyzers available
that use special network drivers, use of permiscuous
network mode, etc., etc. But I'm not looking to watch
any traffic except to and from my local machine on a
known port and I am hoping that this is less complicated
and that .NET's rich netwoking classes will lend a hand.

The two biggest issues that exist are the fact that
windows sockets does not like an port/ip pair bound to
two different sockets. I can sidestep this issue by
using SetSocketOption and SocketOptionNam e.ReuseAddress,
but I have found that simply binding to the address is
not sufficient to create the desired effect.

Any help?
Jul 21 '05 #1
6 6228
Hi Randal,

You may try to see the SetSocketOption function.
But if the other application use the socket as SocketOptionNam e
=ExclusiveAddre ssUse
Then you can not use SetSocketOption to set your socket as
SocketOptionNam e = ReuseAddress which allows the socket to be bound to an
address that is already in use.

Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Randal" <ra****@nospam. com>
Sender: "Randal" <ra****@nospam. com>
Subject: TCP/IP Monitoring in .NET
Date: Thu, 25 Sep 2003 14:38:50 -0700
Lines: 24
Message-ID: <0b************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcODrWig9CK3faw TTni7PrRRY/Zqww==
Newsgroups: microsoft.publi c.dotnet.genera l
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:109938
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.publi c.dotnet.genera l

Does anyone have a code sample of how one would "listen"
to a TCP/IP session between an application on the local
machine and a remote host.

I'm looking for code that would allow me to specify a
local IP and a local port which is already in use by
another application (outside of my control) and simply
watch the traffic.

I know there are open source packet analyzers available
that use special network drivers, use of permiscuous
network mode, etc., etc. But I'm not looking to watch
any traffic except to and from my local machine on a
known port and I am hoping that this is less complicated
and that .NET's rich netwoking classes will lend a hand.

The two biggest issues that exist are the fact that
windows sockets does not like an port/ip pair bound to
two different sockets. I can sidestep this issue by
using SetSocketOption and SocketOptionNam e.ReuseAddress,
but I have found that simply binding to the address is
not sufficient to create the desired effect.

Any help?


Jul 21 '05 #2
Randal,
Does anyone have a code sample of how one would "listen"
to a TCP/IP session between an application on the local
machine and a remote host.


Take a look at this: http://www.mentalis.org/soft/projects/pmon/

fyi: IIRC it's w2k and later only
--
Abderaware
Fine Components For .NET
Turn on, tune in, download.
zane a@t abderaware.com
Jul 21 '05 #3
Exactly what I was looking for! Thanks a million, Zane.
-----Original Message-----
Randal,
Does anyone have a code sample of how one would "listen"to a TCP/IP session between an application on the local
machine and a remote host.
Take a look at this:

http://www.mentalis.org/soft/projects/pmon/
fyi: IIRC it's w2k and later only
--
Abderaware
Fine Components For .NET
Turn on, tune in, download.
zane a@t abderaware.com
.

Jul 21 '05 #4
As noted in my post, I am already using SetSocketOption
with the ReuseAddress option, but I was looking for some
of the specifics of extracting the information, since the
underlying socket is already connected. The issue is
that Socket.Receive cannot be used without the new socket
being connected. I am trying to figure out the specifics
of making a "connection " to the connection that already
exists by the original application.
-----Original Message-----
Hi Randal,

You may try to see the SetSocketOption function.
But if the other application use the socket as SocketOptionNam e=ExclusiveAddr essUse
Then you can not use SetSocketOption to set your socket asSocketOptionNa me = ReuseAddress which allows the socket to be bound to anaddress that is already in use.

Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Randal" <ra****@nospam. com>
Sender: "Randal" <ra****@nospam. com>
Subject: TCP/IP Monitoring in .NET
Date: Thu, 25 Sep 2003 14:38:50 -0700
Lines: 24
Message-ID: <0b************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcODrWig9CK3faw TTni7PrRRY/Zqww==
Newsgroups: microsoft.publi c.dotnet.genera l
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:109938NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.publi c.dotnet.genera l

Does anyone have a code sample of how one would "listen"to a TCP/IP session between an application on the local
machine and a remote host.

I'm looking for code that would allow me to specify a
local IP and a local port which is already in use by
another application (outside of my control) and simply
watch the traffic.

I know there are open source packet analyzers available
that use special network drivers, use of permiscuous
network mode, etc., etc. But I'm not looking to watch
any traffic except to and from my local machine on a
known port and I am hoping that this is less complicatedand that .NET's rich netwoking classes will lend a hand.

The two biggest issues that exist are the fact that
windows sockets does not like an port/ip pair bound to
two different sockets. I can sidestep this issue by
using SetSocketOption and SocketOptionNam e.ReuseAddress,but I have found that simply binding to the address is
not sufficient to create the desired effect.

Any help?


.

Jul 21 '05 #5
Randal,
Does anyone have a code sample of how one would "listen"
to a TCP/IP session between an application on the local
machine and a remote host.


Take a look at this: http://www.mentalis.org/soft/projects/pmon/

fyi: IIRC it's w2k and later only
--
Abderaware
Fine Components For .NET
Turn on, tune in, download.
zane a@t abderaware.com
Jul 21 '05 #6
Hi Randal,

You may try to see the SetSocketOption function. By default, when you new a
socket, it will use the ExclusiveAddres sUse option,
i.e. you can not use SetSocketOption to set your socket as
SocketOptionNam e = ReuseAddress which allows the socket to be bound to an
address that is already in use.
To let the ReuseAddress work, you may need to set the two application all
with ReuseAddress option.
e.g.
Socket listener = new Socket(AddressF amily.InterNetw ork,SocketType. Stream,
ProtocolType.Tc p );
listener.SetSoc ketOption(Socke tOptionLevel.So cket,SocketOpti onName.ReuseAdd r
ess,1);

But, when the latter running application running the SetSocketOption and
bind to the socket, the first running application will no longer get data.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Randal" <ra****@nospam. com>
Sender: "Randal" <ra****@nospam. com>
References: <0b************ *************** *@phx.gbl> <nK************ **@cpmsftngxa06 .phx.gbl>Subject: RE: TCP/IP Monitoring in .NET
Date: Fri, 26 Sep 2003 14:09:55 -0700
Lines: 84
Message-ID: <1e************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOEcojs7W6hWfK 5SUSj1TgJuJCktQ ==
Newsgroups: microsoft.publi c.dotnet.genera l
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:110074
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.publi c.dotnet.genera l

As noted in my post, I am already using SetSocketOption
with the ReuseAddress option, but I was looking for some
of the specifics of extracting the information, since the
underlying socket is already connected. The issue is
that Socket.Receive cannot be used without the new socket
being connected. I am trying to figure out the specifics
of making a "connection " to the connection that already
exists by the original application.
-----Original Message-----
Hi Randal,

You may try to see the SetSocketOption function.
But if the other application use the socket as

SocketOptionNa me
=ExclusiveAdd ressUse
Then you can not use SetSocketOption to set your socket

as
SocketOptionN ame = ReuseAddress which allows the socket

to be bound to an
address that is already in use.

Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Randal" <ra****@nospam. com>
Sender: "Randal" <ra****@nospam. com>
Subject: TCP/IP Monitoring in .NET
Date: Thu, 25 Sep 2003 14:38:50 -0700
Lines: 24
Message-ID: <0b************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcODrWig9CK3faw TTni7PrRRY/Zqww==
Newsgroups : microsoft.publi c.dotnet.genera l
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gblmicrosoft.publ ic.dotnet.gener al:109938NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.publi c.dotnet.genera l

Does anyone have a code sample of how onewould "listen"to a TCP/IP session between an application on the local
machine and a remote host.

I'm looking for code that would allow me to specify a
local IP and a local port which is already in use by
another application (outside of my control) and simply
watch the traffic.

I know there are open source packet analyzers available
that use special network drivers, use of permiscuous
network mode, etc., etc. But I'm not looking to watch
any traffic except to and from my local machine on a
known port and I am hoping that this is lesscomplicatedand that .NET's rich netwoking classes will lend a hand.

The two biggest issues that exist are the fact that
windows sockets does not like an port/ip pair bound to
two different sockets. I can sidestep this issue by
using SetSocketOption andSocketOptionNa me.ReuseAddress ,but I have found that simply binding to the address is
not sufficient to create the desired effect.

Any help?


.


Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2026
by: Sven Dzepina | last post by:
Hi All, how I can make a simply HostWatch - system which use a mysql DB and send me an e-Mail if the Server goes off and again on? I began to programm this last night, but the MySQL inquiry is too hard for me! =( Thats my code: ----
1
3890
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I get the following error: Invalid file name for monitoring: 'E:\'. File names for monitoring must have absolute paths, and no wildcards. Description: An unhandled exception occurred during the
0
1867
by: Jay Blanchard | last post by:
-----Original Message----- From: Moritz Steiner =20 Sent: Wednesday, July 16, 2003 10:46 AM To: Jay Blanchard Subject: AW: monitoring I want to see: Number of queries =20
4
2239
by: johnm | last post by:
Hello, We currently are running a CRM application that uses DB/2 7.2 for the data repository. We will be upgrading to 8.2 later this year....maybe....time and resources permitting. The database is currently being hosted with a managed service provider (MSP) at a remote datacenter. This service provider is supposed to be monitoring the health and performance of the database as well as performing proactive maintenance on a regularly...
3
2326
by: JSheble | last post by:
I have a windows service that in the OnStart it creates a thread and runs a loop forever and ever, assuming the service is running. The loop stops during the OnStop event, and everything works exactly as expected. I also have an application that monitors that service using the ServiceController component, and allows me to start & stop the service as needed, as well as poll for it's current status. Still everything thus far works and...
0
2095
by: Jeff Reed | last post by:
I am experiencing the the problem outlined the below. Unfortunately, I am using WinXP and I not sure if I can apply the solution due to lack of security control Any feed back would be apreciated http://support.microsoft.com/default.aspx?scid=kb;EN-US;31795 FIX: "Failed to Start Monitoring Directory Changes" Error Message When You Browse to an ASP.NET Pag View products that this article applies to This article was previously...
0
1620
by: Ron Simpson | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I get the following error: Invalid file name for monitoring: 'E:\'. File names for monitoring must have absolute paths, and no wildcards. Description: An unhandled exception occurred during the
9
3215
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My questions are below... "David Good" wrote: > We have a network running both Win2k and Win2k3 webservers and our web sites > reside on a UNC network share that happens to be a Network Appliance NAS.
4
1557
by: Bob | last post by:
I've got dot net Winform apps that are running in a backroom server with no user interaction. They are supposed to run unattended 24 7 365. They are IVR apps taking orders via telephony. Problem is nobody is looking at them to know if they are OK. They have err trapping built in and there's logging and tracing to log files, but nobody there looks at that. What I need is to find a way to advise one or more managers immediately when an app is...
4
1537
by: natG | last post by:
Well folks, I didn't heed the warnings (that excessive monitoring, statistics, etc. can cause a performance hit) and I have been playing around with all kinds of monitors, snapshots, especially with the gui. BUT! Performance has dropped 70%! The monitors show that the the most system overhead is caused by these selects themselves. Question 1: Is there a big red switch that turns OFF *all* of this type of activity! Question 2: If so, can I...
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.