Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Re: System.Net.Sockets.Tcplistener (http://www.velocityreviews.com/forums/t19569-re-system-net-sockets-tcplistener.html)

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

Re: System.Net.Sockets.Tcplistener
 
Hi!

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);
tcpListen.Start();

while(1)
{
while(tcpListen.Pending()==true)
{
// 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
}

Regards,
Gaurav Khanna
--
----------------------------------------------------------------------------
----------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
----------------------------------------------------------------------------
----------

"MB" <marcoyukon@hotmail.com> wrote in message
news:uhm0nbGTDHA.2316@tk2msftngp13.phx.gbl...
> I am new to sockets programming, but I need something that seems to be

very
> 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

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

bit
> 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.