Thanks for the help! The examples were simple and I now have my program working correctly :). These are probably the clearest and the best examples around.
But one thing was missing from all these examples... remember timeouts? Timeouts are nice. The recv waits for data till the end of times if the target host was down. Don't forget that :)