I'm planning on making a game which multiple people can play over a network. I've never done any programming involving a network, so I have lots of questions.

1) Do I need a third-party library to open ports and transmit data?

2) What protocol should be used? I don't know the differences between TCP/IP and UDP.

3) What changes would I have to make to play this over a LAN network, as opposed to the Internet?

4) How should I make sure that all versions of the game world are synced properly? I'm thinking of initializing one copy per computer, then only sending events like 'move up' or 'attack' between the computers, so not as much data needs to be sent. Is there a better way, or is this good enough?

5) If I do that, how do I make sure that I don't have timing issues? For example, A receives two events from C and D simultaneously, but B receives C's later, which could alter the internal state of the world.

6) How should I make sure that random numbers are the same between all computers? Should I just send requests to one computer and have it send out a random number? Seems inefficient...