Online games - are very complex thing, but core principle is simple.
TCP/IP protocol is usually used. UDP to send broadcast requests and locate clients, when playing on LAN. TCP/IP connection - is usually just a stream, similar to file stream. You can read from it and write to it - data format is arbitrary, as in case of files. IP address and port are used to identify every connection. Client can have only one such stream, while sever can have any number of such streams. Server usually listens some port. Client connects to this port, but when connection is accepted new unused port is allocated and assigned to this client, so every client has his unique connection. So, it's all about writing to connection, waiting for data to appear on connection and reading data from it.
How game itself works? You choose some framerate. Frame - is game time unit. 60 frames per second for example. Everything else is like in any other game - you read player's input and update state of your game on every frame. Only difference - parts of your game, like server and clients, have to send this state or update of this state to each other via network connections.