I have been working on some socket related programming for a windows platform and I have found that my programs only work when I am connected to a router. I originally installed windows on a laptop (SP) so I could test a pair of UDP programs (attached) but I did not want to install security programs on the machine so I decided not to EVER connect it to the internet. However, I found that unless I connected the machine to at least a router, the programs would not work. I thought they would communicate over localhhost no matter what, but that does not appear to be true and I don't understand why.
When connected to the other machine, this is what the ipconfig and routing table looks like:
There is nothing wrong with your code; it is another Windows "helpful feature" that MS added to XP. When XP does not detect a network not even the loopback addresses will work. The way to get around this issue is to install the loopback network adapter. Here are the full instructions form a Microsoft article:
1. Click Start, and then click Control Panel.
2. If you are in Classic view, click Switch to Category View under Control Panel in the left pane.
3. Double-click Printers and Other Hardware, and then click Next.
4. Under See Also in the left pane, click Add Hardware,and then click Next.
5. Click Yes, I have already connected the hardware, and then click Next.
6. At the bottom of the list, click Add a new hardware device, and then click Next.
7. Click Install the hardware that I manually select from a list, and then click Next.
8. Click Network adapters, and then click Next.
9. In the Manufacturer box, click Microsoft.
10. In the Network Adapter box, click Microsoft Loopback Adapter, and then click Next.
11. Click Finish.