C# SharpPCap Read Packet Content -


i'm tryin' read content of packets i've captured sharppcap. little code

private void button4_click(object sender, eventargs e)         {             // retrieve device list             var devices = libpcaplivedevicelist.instance;              // extract device list             var device = devices[1];              // register our handler function             // 'packet arrival' event             device.onpacketarrival +=                 new sharppcap.packetarrivaleventhandler(device_onpacketarrival);              // open device capturing             int readtimeoutmilliseconds = 1000;             if (device airpcapdevice)             {                 // note: airpcap devices cannot disable local capture                 var airpcap = device airpcapdevice;                 airpcap.open(sharppcap.winpcap.openflags.datatransferudp, readtimeoutmilliseconds);             }             else if (device winpcapdevice)             {                 var winpcap = device winpcapdevice;                 winpcap.open(sharppcap.winpcap.openflags.datatransferudp | sharppcap.winpcap.openflags.nocapturelocal, readtimeoutmilliseconds);             }             else if (device libpcaplivedevice)             {                 var livepcapdevice = device libpcaplivedevice;                 livepcapdevice.open(devicemode.promiscuous, readtimeoutmilliseconds);             }             else             {                 throw new system.invalidoperationexception("unknown device type of " + device.gettype().tostring());             }              device.open(devicemode.promiscuous, readtimeoutmilliseconds);              device.startcapture();              messagebox.show("-- listening on {0}, hit 'enter' stop...",                 device.description);              // stop capturing process             device.stopcapture();              // close pcap device             device.close();          }  private static void device_onpacketarrival(object sender, captureeventargs e)         {             if (e.packet.linklayertype == packetdotnet.linklayers.ethernet)             {                 var packet = packetdotnet.packet.parsepacket(e.packet.linklayertype, e.packet.data);                 var ethernetpacket = (packetdotnet.ethernetpacket)packet;                  messagebox.show(system.text.encoding.ascii.getstring(e.packet.data));                 packetindex++;             }         } 

i capture byte[] packet don't know how can read whole server response. thank help


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -