UDP Network game problem ...
Hello,
i need some help.
I''m making an udp network engine, and I would like to receive only from IP that I specified in a SOCKADDR struct .. can you help me with some code???
Thanks..
Sorry for my english..
You should look into connected UDP sockets if there is a compelling reason for you to use this method. Using connect() with UDP is somewhat misleading, so make sure you read up on it before you blindly trust what is going on... Stevens has a good treatment on connect() with UDP.
Essentially you would have to track the connected clients within your server. One suggestion would be to store the IP addresses of the connected clients in a std::map. So, when a client connects to the server using the login protocol that you create (udp is connectionless) you would go through the usual validation of username and password then store the IP address in the std::map – then as further messages are received by the server you would have to verify that the IP address is in the connected list of clients.
Using a std::map allows you to quickly lookup the IP address over a std::list or std::vector. And I would be amiss to mention that there is more to this than that which I have alluded to but, this _is_ the general ideal.
Dave "Dak Lozar" Loeser
Using a std::map allows you to quickly lookup the IP address over a std::list or std::vector. And I would be amiss to mention that there is more to this than that which I have alluded to but, this _is_ the general ideal.
Dave "Dak Lozar" Loeser
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement