How can I get a raw package from a client?

I want to receive raw packet data from a client, and I read this message:
C # Receiving packet data
but I cannot understand this line:

s.Bind(new IPEndPoint(IPAddress.Parse(strIP), 80));
log(System.Text.Encoding.ASCII.GetString(buffer, 0, bytes));
  • strIPwhat server ip?
  • What makes a call log?
+4
source share
3 answers

strIP is a variable that contains the IP address of the endpoint.

The line log()should write a line version of what is received - perhaps in a log file somewhere that was previously defined in the code.

+1
source
strIP = Net.Dns.GetHostEntry(Net.Dns.GetHostName()).AddressList[0].ToString();

To get the local IP address.

And it log()should look like this.

private void log(string log)
{
    Console.WritelLine(log); //or append this text in any text file 
}
0
source

I suggest using the pcapDotNet library in C #. https://pcapdotnet.codeplex.com/

0
source

All Articles