Connect with UDP?
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.
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.
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.
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.
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.
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?
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.
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.
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]
Quote:Original post by CodaKillerSounds like your expectations may be unrealistic. What specifically did not appeal about RakNet (which, incidentally, is free for Indie use).
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...
Quote:Original post by swiftcoderQuote:Original post by CodaKillerSounds like your expectations may be unrealistic. What specifically did not appeal about RakNet (which, incidentally, is free for Indie use).
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...
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement