473,386 Members | 1,764 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,386 software developers and data experts.

How can i detect TCP/Ip pcaketsin cSharp

Hi all,
I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet in
c#.Net.Any body knows please tell me, what are the interfaces or classes
are
supported regrading on TCP/IP packets.Please tell me any website refrences
or any Source code examples.This is very urgent requirement.

Thanks in advance,
Regards,
Tulasi Kumar.


Dec 26 '05 #1
5 2170
It depends on what level you want to work.

In .NET the functionality you need is in System.Net and System.NET.Sockets
namespaces.

Socket class supports different types of socket ( stream, dgram, raw )

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:Ov**************@TK2MSFTNGP15.phx.gbl...
Hi all,
I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet
in
c#.Net.Any body knows please tell me, what are the interfaces or classes
are
supported regrading on TCP/IP packets.Please tell me any website
refrences
or any Source code examples.This is very urgent requirement.

Thanks in advance,
Regards,
Tulasi Kumar.



Dec 26 '05 #2
Thank u for giving the reply.
When ever any data is coming to the TCP/IP port i will take the data and
do some operations on that packet.Before doing the operations I have to take
the Packet data.How can i get the packet data from TCP port? can u give me
ur help regarding on this.

thanks in advance.
Regards,
Tulaskumar

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
It depends on what level you want to work.

In .NET the functionality you need is in System.Net and System.NET.Sockets namespaces.

Socket class supports different types of socket ( stream, dgram, raw )

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:Ov**************@TK2MSFTNGP15.phx.gbl...
Hi all,
I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet in
c#.Net.Any body knows please tell me, what are the interfaces or classes are
supported regrading on TCP/IP packets.Please tell me any website
refrences
or any Source code examples.This is very urgent requirement.

Thanks in advance,
Regards,
Tulasi Kumar.






Dec 26 '05 #3
Check the docs for the TcpClient and TcpListener

TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("www.contoso.com", 11002);
NetworkStream netStream = tcpClient.GetStream ();

if (netStream.CanWrite)
{
Byte[] sendBytes = Encoding.UTF8.GetBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Length);
}
else
{
Console.WriteLine ("You cannot write data to this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}

if (netStream.CanRead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.ReceiveBufferSize];

// Read can return anything from 0 to numBytesToRead.
// This method blocks until at least one byte is read.
netStream.Read (bytes, 0, (int)tcpClient.ReceiveBufferSize);

// Returns the data received from the host to the console.
string returndata = Encoding.UTF8.GetString (bytes);

Console.WriteLine ("This is what the host returned to you: " +
returndata);

}
else
{
Console.WriteLine ("You cannot read data from this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}
netStream.Close();
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:eZ**************@TK2MSFTNGP11.phx.gbl...
Thank u for giving the reply.
When ever any data is coming to the TCP/IP port i will take the data and
do some operations on that packet.Before doing the operations I have to
take
the Packet data.How can i get the packet data from TCP port? can u give me
ur help regarding on this.

thanks in advance.
Regards,
Tulaskumar

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sockets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw )
>
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKumar" <tu*********@nannacomputers.com> wrote in message
> news:Ov**************@TK2MSFTNGP15.phx.gbl...
> > Hi all,
> > I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip packet > > in
> > c#.Net.Any body knows please tell me, what are the interfaces or classes > > are
> > supported regrading on TCP/IP packets.Please tell me any website
> > refrences
> > or any Source code examples.This is very urgent requirement.
> >
> > Thanks in advance,
> > Regards,
> > Tulasi Kumar.
> >
> >
> >
> >
> >
> >
> >
> >

>
>


Dec 26 '05 #4
My heartful thanks to Vadym Stetsyak giving ur immediate reply.I will try
it.In this way,I have struck up from few days.Where i have to go u r giving
the way.I will try it and i will give the result regarding on this.Once
again very very thanks Vadym Stetsyak
Regrads
tulasi kumar
"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:ug*************@TK2MSFTNGP15.phx.gbl...
Check the docs for the TcpClient and TcpListener

TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("www.contoso.com", 11002);
NetworkStream netStream = tcpClient.GetStream ();

if (netStream.CanWrite)
{
Byte[] sendBytes = Encoding.UTF8.GetBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Length);
}
else
{
Console.WriteLine ("You cannot write data to this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}

if (netStream.CanRead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.ReceiveBufferSize];

// Read can return anything from 0 to numBytesToRead.
// This method blocks until at least one byte is read.
netStream.Read (bytes, 0, (int)tcpClient.ReceiveBufferSize);

// Returns the data received from the host to the console.
string returndata = Encoding.UTF8.GetString (bytes);

Console.WriteLine ("This is what the host returned to you: " +
returndata);

}
else
{
Console.WriteLine ("You cannot read data from this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}
netStream.Close();
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:eZ**************@TK2MSFTNGP11.phx.gbl...
Thank u for giving the reply.
When ever any data is coming to the TCP/IP port i will take the data and do some operations on that packet.Before doing the operations I have to take
the Packet data.How can i get the packet data from TCP port? can u give me ur help regarding on this.

thanks in advance.
Regards,
Tulaskumar

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sockets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw ) >
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKumar" <tu*********@nannacomputers.com> wrote in message
> news:Ov**************@TK2MSFTNGP15.phx.gbl...
> > Hi all,
> > I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip

packet
> > in
> > c#.Net.Any body knows please tell me, what are the interfaces or

classes
> > are
> > supported regrading on TCP/IP packets.Please tell me any website
> > refrences
> > or any Source code examples.This is very urgent requirement.
> >
> > Thanks in advance,
> > Regards,
> > Tulasi Kumar.
> >
> >
> >
> >
> >
> >
> >
> >
>
>





Dec 26 '05 #5
hi Vadym Stetsyak,
i have prepared one windows service in c#.net .This is service about TcpIp
packets data checking.I had wrriten the code as per your advice.so,my
problem is how can i insatll this windows service.please tell me ur advice
,i greatly revice ur advice.

thanks in advance
regards
tulasi

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:ug*************@TK2MSFTNGP15.phx.gbl...
Check the docs for the TcpClient and TcpListener

TcpClient tcpClient = new TcpClient ();
tcpClient.Connect ("www.contoso.com", 11002);
NetworkStream netStream = tcpClient.GetStream ();

if (netStream.CanWrite)
{
Byte[] sendBytes = Encoding.UTF8.GetBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Length);
}
else
{
Console.WriteLine ("You cannot write data to this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}

if (netStream.CanRead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.ReceiveBufferSize];

// Read can return anything from 0 to numBytesToRead.
// This method blocks until at least one byte is read.
netStream.Read (bytes, 0, (int)tcpClient.ReceiveBufferSize);

// Returns the data received from the host to the console.
string returndata = Encoding.UTF8.GetString (bytes);

Console.WriteLine ("This is what the host returned to you: " +
returndata);

}
else
{
Console.WriteLine ("You cannot read data from this stream.");
tcpClient.Close ();

// Closing the tcpClient instance does not close the network stream.
netStream.Close ();
return;
}
netStream.Close();
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"TulasiKumar" <tu*********@nannacomputers.com> wrote in message
news:eZ**************@TK2MSFTNGP11.phx.gbl...
Thank u for giving the reply.
When ever any data is coming to the TCP/IP port i will take the data and do some operations on that packet.Before doing the operations I have to take
the Packet data.How can i get the packet data from TCP port? can u give me ur help regarding on this.

thanks in advance.
Regards,
Tulaskumar

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sockets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw ) >
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKumar" <tu*********@nannacomputers.com> wrote in message
> news:Ov**************@TK2MSFTNGP15.phx.gbl...
> > Hi all,
> > I am new in Netwrok porgraming in cSharp.how can i detect Tcp/Ip

packet
> > in
> > c#.Net.Any body knows please tell me, what are the interfaces or

classes
> > are
> > supported regrading on TCP/IP packets.Please tell me any website
> > refrences
> > or any Source code examples.This is very urgent requirement.
> >
> > Thanks in advance,
> > Regards,
> > Tulasi Kumar.
> >
> >
> >
> >
> >
> >
> >
> >
>
>





Dec 29 '05 #6

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

Similar topics

1
by: Gouri | last post by:
How fo you detect whether the client machine has a modem attached to it with VB.NET or C#
4
by: Frank Meng | last post by:
Hi. I am trying a csharp sample from http://www.codeproject.com/csharp/socketsincs.asp . (Sorry I didn't post all the source codes here, please get the codes from above link if you want to try)....
2
by: Roger Maynard | last post by:
Hello List, I have a FileStream which I then read with a BinaryReader. Is there a better way of detecting EOF other than letting it throw an exception??
1
by: Mamatha | last post by:
Hi, I have a video capturing with motion detection application in C#.NET.In that application i detected all resources i.e video source and audion source thourgh motion detection,now i want to...
3
by: akowald | last post by:
There's another topic like this but the code posted is in VB.NET. Well I need some help detecting mouse clicks outside the form. An event handler would be great but I can work with anything. ...
2
by: yxq | last post by:
Hello, How to detect the OS info that is x86 or x64 in Windows XP? Thank you
3
by: dw | last post by:
stilHello... Is there a way to detect a person's time zone and/or country when they browse to a site? I want to dynamically display controls and labels based on the user's time zone or...
4
by: dgk | last post by:
For the whole machine, not a specific process. I looked at an earlier thread by Cor and Ken Tucker, but I don't find anything in the management that looks like... Oh. Here is a really good site....
3
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all mister, Which is THE BEST WAY IN THE WORLD AROUND for: 1. detect Network
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.