Velocity Reviews

Velocity Reviews (
-   ASP .Net (
-   -   Re: System.Net.Sockets.Tcplistener (

Gaurav Khanna [.NET MVP] 07-25-2003 12:34 PM

Re: System.Net.Sockets.Tcplistener

If the port is already being "listened" upon by another application, then
you will need to sniff on the incoming packets to determine the data you
wish to work upon. However, if you have to write the application to "listen"
on a specified port, wait for an incoming stream of data and then work upon
the data, then System.Net.Socket.TcpListener is what you are looking for.
Here's a sample pseudo code that will listen on port 2323:

TcpListener tcpListen = new TcpListener(2323);

// accept an incoming request...
TcpClient tcpClient = tcpListen.AcceptTcpClient();

// ask another thread to work on the client so that this thread can
listen for more incoming requests...

// make the current thread sleep here so that the CPU can relax

Gaurav Khanna
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
OpSupport - Spelunking Rotor

"MB" <> wrote in message
> I am new to sockets programming, but I need something that seems to be

> simple.
> I need to monitor a port on a server running a background application in
> order to integrate to another application. I know the port number and the
> vendor will provide me the binary sequence of the data stream going to

> port. This is all they will provide.
> On this stream (among other info) I will receive an active or inactive

> that represents the state of the application icon on the system tray. When
> active it turns green, when inactive it turns red.
> Is it possible to snoop this port using the namespace
> System.Net.Sockets.Tcplistener or another namespace ?
> Is it possible to read the data stream without affecting the backgound
> application, which is also reading the stream.
> Thanks a lot
> Marco

All times are GMT. The time now is 02:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.