4

I want to get raw packet data from client and I read this post:
C# Getting packet data
but I can't understand this line:

s.Bind(new IPEndPoint(IPAddress.Parse(strIP), 80));
log(System.Text.Encoding.ASCII.GetString(buffer, 0, bytes));
  1. strIP, is that the server ip?
  2. what does the log call do?
Community
  • 1
  • 1
elnaz irani
  • 277
  • 1
  • 3
  • 11

3 Answers3

1

The strIP is the variable that holds the IP address of the endpoint.

The log() line is to log a string version of what is received - probably to a log file somewhere that is defined earlier in the code.

Rob Aston
  • 816
  • 12
  • 19
0
strIP = Net.Dns.GetHostEntry(Net.Dns.GetHostName()).AddressList[0].ToString();

To get your local ip address.

And the log() should be look like this.

private void log(string log)
{
    Console.WritelLine(log); //or append this text in any text file 
}
Shell
  • 6,818
  • 11
  • 39
  • 70
0

I suggest use the pcapDotNet library in c#. https://pcapdotnet.codeplex.com/

Ahmad
  • 906
  • 11
  • 27