473,545 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2176
It depends on what level you want to work.

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

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

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

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:Ov******** ******@TK2MSFTN GP15.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.ne t> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
It depends on what level you want to work.

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

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

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

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:Ov******** ******@TK2MSFTN GP15.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.Conne ct ("www.contoso.c om", 11002);
NetworkStream netStream = tcpClient.GetSt ream ();

if (netStream.CanW rite)
{
Byte[] sendBytes = Encoding.UTF8.G etBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Lengt h);
}
else
{
Console.WriteLi ne ("You cannot write data to this stream.");
tcpClient.Close ();

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

if (netStream.CanR ead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.Recei veBufferSize];

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

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

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

}
else
{
Console.WriteLi ne ("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

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:eZ******** ******@TK2MSFTN GP11.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.ne t> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sock ets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw )
>
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
> news:Ov******** ******@TK2MSFTN GP15.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.ne t> wrote in message
news:ug******** *****@TK2MSFTNG P15.phx.gbl...
Check the docs for the TcpClient and TcpListener

TcpClient tcpClient = new TcpClient ();
tcpClient.Conne ct ("www.contoso.c om", 11002);
NetworkStream netStream = tcpClient.GetSt ream ();

if (netStream.CanW rite)
{
Byte[] sendBytes = Encoding.UTF8.G etBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Lengt h);
}
else
{
Console.WriteLi ne ("You cannot write data to this stream.");
tcpClient.Close ();

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

if (netStream.CanR ead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.Recei veBufferSize];

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

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

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

}
else
{
Console.WriteLi ne ("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

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:eZ******** ******@TK2MSFTN GP11.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.ne t> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sock ets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw ) >
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
> news:Ov******** ******@TK2MSFTN GP15.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.ne t> wrote in message
news:ug******** *****@TK2MSFTNG P15.phx.gbl...
Check the docs for the TcpClient and TcpListener

TcpClient tcpClient = new TcpClient ();
tcpClient.Conne ct ("www.contoso.c om", 11002);
NetworkStream netStream = tcpClient.GetSt ream ();

if (netStream.CanW rite)
{
Byte[] sendBytes = Encoding.UTF8.G etBytes ("Is anybody there?");
netStream.Write (sendBytes, 0, sendBytes.Lengt h);
}
else
{
Console.WriteLi ne ("You cannot write data to this stream.");
tcpClient.Close ();

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

if (netStream.CanR ead)
{
// Reads NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.Recei veBufferSize];

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

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

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

}
else
{
Console.WriteLi ne ("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

"TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
news:eZ******** ******@TK2MSFTN GP11.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.ne t> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> It depends on what level you want to work.
>
> In .NET the functionality you need is in System.Net and

System.NET.Sock ets
> namespaces.
>
> Socket class supports different types of socket ( stream, dgram, raw ) >
> --
> Vadym Stetsyak aka Vadmyst
> http://vadmyst.blogspot.com
>
> "TulasiKuma r" <tu*********@na nnacomputers.co m> wrote in message
> news:Ov******** ******@TK2MSFTN GP15.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
436
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
3830
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). I had some troubles when I started 6 threads (each thread made a separate connection) and sent messages to same server simultaneously. Sometimes,...
2
2185
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
2889
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 capture that live video into wmv file.Now i want help from you in the case of how can we detect the video from control like a picture,i used...
3
28555
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. Thanks in advance, Alex
2
5950
by: yxq | last post by:
Hello, How to detect the OS info that is x86 or x64 in Windows XP? Thank you
3
11819
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 country.....if possible. thanks - will
4
2634
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. Really, I don't know the guy but just found it via Google. I guess I don't need to post this anymore but just in case someone else is looking for the...
3
3580
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
7405
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...
0
7659
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. ...
1
7428
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7760
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...
0
5975
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5334
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...
0
4949
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...
0
3455
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...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.