Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

Connect with UDP?

This topic is 3250 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to send the IP of the connecting client to the server to do NAT punch-through with UDP. I could do this with recvfrom but I would have to use a key word, I was thinking about using connect and accept to request a connection but I can't seem to get it to work, does it require a TCP socket? The documents make it sound like it does but I'm not 100% sure.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by swiftcoder
What on Earth is the 'keyword' meant to accomplish? Just call recvfrom(), and whatever packet arrives will give you the address of the other end.


recvfrom() works without any data being sent? Also I have to verify the client to make sure it's a valid game client not something else, the key word would be to tell the server it is a game client trying to connect.

Share this post


Link to post
Share on other sites
How is the communication with the match maker done at the moment? UDP is connectionless, so connect() and accept() have no real meaning.

You can put some dummy value in a UDP packet if you only care about the address and nothing else. Its usually a good idea to include some kind of protocol specific data, even if its only a magic number, just in case your chosen port number clashes with some other application.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
How is the communication with the match maker done at the moment? UDP is connectionless, so connect() and accept() have no real meaning.

You can put some dummy value in a UDP packet if you only care about the address and nothing else. Its usually a good idea to include some kind of protocol specific data, even if its only a magic number, just in case your chosen port number clashes with some other application.


Alright let me explain what I'm doing, I am creating a game engine which uses lua scripting, I'm trying to give the engine the ability to be both a client and a server through scripting, the idea is to call a function from the client called create_server which triggers the On_Connect even on the server.

In the event you can return either ture or false depending on if you want to accept the connection or not, if the server accepts the connection it returns an instance of my socket class which contains the IP and port of the server.

The server also gets an instance of a socket for the client from the connection event. After the client is connected any data sent using the socket to the server will trigger the On_Receive event and vice versa.

How do most games request a connection from a server, like do they send a data packet with a request code, or do they just use the TCP connect and accept commands for this?

Like for instance if I know the IP and port of a Left 4 Dead server could I just create a program which calls the connect command and actually get a connection?

Share this post


Link to post
Share on other sites
You could use an existing high-level networking library that allow you to treat UDP as a connection oriented protocol with (typically) optional ordering and reliability and duplicate packet detection. Check out the Forum FAQ for a list of such libraries.

Alternatively, you would have to do that yourself. This will take some time, be error prone and probably result in a weaker library than the ones mentioned above. Not a great option.

Either way, I'm not sure what this has to do with NAT punch through. Do you have a matchmaking service? Without it, you can't do NAT punch through.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
You could use an existing high-level networking library that allow you to treat UDP as a connection oriented protocol with (typically) optional ordering and reliability and duplicate packet detection. Check out the Forum FAQ for a list of such libraries.

Alternatively, you would have to do that yourself. This will take some time, be error prone and probably result in a weaker library than the ones mentioned above. Not a great option.

Either way, I'm not sure what this has to do with NAT punch through. Do you have a matchmaking service? Without it, you can't do NAT punch through.


I understand the concept, the idea is that any server you connect to with the create_server command would have to be directly connection to the internet or it will fail. Maybe a high level library would be a better idea, thanks for the suggestion, I'll look in to that.

EDIT: None of the high-level libraries look appealing to me, only one which is standard is under a commercial licence and I'm sure it cost a lot...

[Edited by - CodaKiller on October 24, 2009 2:03:00 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
EDIT: None of the high-level libraries look appealing to me, only one which is standard is under a commercial licence and I'm sure it cost a lot...
Sounds like your expectations may be unrealistic. What specifically did not appeal about RakNet (which, incidentally, is free for Indie use).

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by CodaKiller
EDIT: None of the high-level libraries look appealing to me, only one which is standard is under a commercial licence and I'm sure it cost a lot...
Sounds like your expectations may be unrealistic. What specifically did not appeal about RakNet (which, incidentally, is free for Indie use).


I'm not really digging this part in their licence "Must display RakNet logo in your game's splash screen or credits." since there is no way for me to do that in the engine which I plan to open source.

Share this post


Link to post
Share on other sites
Actually, there is an open source library that might fulfill CodaKiller's expectations. It's called ENet, and its source is available and used in the Sauerbraten (Cube 2) game engine. It implements higher level functionality on top of UDP, so your data should be more or less reliable, with a dynamic throttling algorithm to boot (to deal with congested networks) and the ability to fragment and reassemble packets transparently. It even has an "enet_host_create" function analogous to CodaKiller's "create_server" function.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!