473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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 SocketOptionName.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 6197
Hi Randal,

You may try to see the SetSocketOption function.
But if the other application use the socket as SocketOptionName
=ExclusiveAddressUse
Then you can not use SetSocketOption to set your socket as
SocketOptionName = 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: AcODrWig9CK3fawTTni7PrRRY/Zqww==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109938
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

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 SocketOptionName.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 SocketOptionName=ExclusiveAddressUse
Then you can not use SetSocketOption to set your socket asSocketOptionName = 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: AcODrWig9CK3fawTTni7PrRRY/Zqww==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:109938NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

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 SocketOptionName.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 ExclusiveAddressUse option,
i.e. you can not use SetSocketOption to set your socket as
SocketOptionName = 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(AddressFamily.InterNetwork,SocketType.Strea m,
ProtocolType.Tcp );
listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddr
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: AcOEcojs7W6hWfK5SUSj1TgJuJCktQ==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:110074
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.general

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

SocketOptionName
=ExclusiveAddressUse
Then you can not use SetSocketOption to set your socket

as
SocketOptionName = 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: AcODrWig9CK3fawTTni7PrRRY/Zqww==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.general:109938NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

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 andSocketOptionName.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
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...
1
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...
0
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
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...
3
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...
0
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 ...
0
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...
9
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...
4
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...
4
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.