Well, you better check to make sure a short is two bytes and a int is 32. Better to use something defined for this.
Instead of re inventing the world, why not look at Gtk-Gnutella, Gnut or Napshare? Then you could move on beyond the simple communications stuff.
The IP should be byte order, just...