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