3 ms·
"Your program communicates with something on a network, but some of the information it’s sending is wrong? It’s probably sending it with write, sendto, or send.
by greenyoda 13y ago
"Your program communicates with something on a network, but some of the information it’s sending is wrong? It’s probably sending it with write, sendto, or send."
If you want to debug network traffic, a higher-level tool like Wireshark[1] (which knows about the packet formats for all sorts of different wire protocols and has sophisticated tools for filtering out just the packets you're interested in seeing) would be much easier to use than looking at system call traces.
Still, this is a great article, and I definitely agree that learning about your operating system's debugging facilities is useful, but in many cases you can save yourself a lot of time by using a tool that's optimized for a particular task.
[1] https://en.wikipedia.org/wiki/Wireshark https://en.wikipedia.org/wiki/Wireshark
- Retric 13y agoThe nice thing about learning to use the UNIX approach is you can use that output as you would any other stream. So, grep it and save that it to a file or any of those other 1001 fun unix things.
- anaphor 13y agoHere is a good way I've found to debug network based code: Step 1: write shell scripts to capture certain kinds of network traffic with tcpdump and output a pcap file (e.g. have a certain function to capture HTTP traffic of a certain kind) Step 2: open with wireshark and split screen with source code I'm sure wireshark has a nice way of doing step 1 but I prefer the workflow of typing "foocap example.org" and then looking at the results in wireshark.