Advent
Advent

Reputation: 158

C++ SFML UDP Socket receiving and sending data to multiple clients

I am trying to learn network socket programming basics and I can't understand some things. I have assignment to create working MMORPG server-client application where even up to 1000 clients can be connected at same time to server using SFML library. I started with some simple stuff like testing packets, sockets and making simple applications like chat in console and multiplayer tic-tac-toe for other assignment. I heard that using UDP sockets is way to go for real-time applications like games so I am trying to understand how does it work. In TCP Socket I am simply listening to connections, once client connects I can assign him to certain socket and keep listening for connections while I send data and identify him.

I don't know how to identify clients using UDP socket. I am not even sure if my approach is right.

I thought that it should work like this:

1.I create UDP socket binding it to certain port.

2.I am making sure that client got permission to receive data from server.

3.In loop I am receiving and sending packets from/to every client.

4.If client get disconnected, we close connection for him/delete him from vector of clients.

So how I do this with UDP sockets? Are they necessary for this kind of architecture ? Also I would appreciate any good article about making working client-server application with good protection and performance. Thanks in advance :)

Upvotes: 1

Views: 1760

Answers (1)

Advent
Advent

Reputation: 158

Okay so I found actually two good articles about using UDP sockets and overall network in game:

SFML Game Development by Example: https://www.packtpub.com/game-development/sfml-game-development-example

Author is writing 3 SFML games in C++ and explains everything as he goes, using UDP sockets and taking care of packet reliability included.

Gaffer on Games article: http://gafferongames.com/networking-for-game-programmers/

Big amount of informations about game networking.

I hope that it helps for someone looking for clues about UDP sockets and examples of using it in network game development.

Upvotes: 2

Related Questions