Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1292736 Posts in 57379 Topics- by 48430 Members - Latest Member: _PixelABCD

April 29, 2017, 01:27:47 am

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityCompetitionsVersus (Moderator: Melly)Networking Solutions or: How Do I Play Over The Tubes?
Pages: 1 2 [3] 4 5
Print
Author Topic: Networking Solutions or: How Do I Play Over The Tubes?  (Read 26316 times)
Toeofdoom
Level 2
**



View Profile WWW
« Reply #40 on: January 17, 2011, 11:26:04 pm »

Syncing is always a bit of an issue... you can go for something fully deterministic (even avoiding floats if they mess it up), though you want the simulation to be light on the CPU that way so it can catch up. This sort of thing is what I mean: http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php

Of course, that tends to rule out standard physics engines, but it's easy for whoever's making a multiplayer roguelike. I hope someone does that Smiley
Logged

bateleur
Level 10
*****



View Profile
« Reply #41 on: January 18, 2011, 02:08:57 am »

I would be disappointed if hardly anyone made any offline multiplayer games for this compo.

I'd quite like to make a game that can be played across two (or more) laptops with wireless capability but without the need for a separate router or network. Does anyone know if that's feasible? (I'd prefer to use Unity or Flash for dev speed reasons...)
Logged

ink.inc
Guest
« Reply #42 on: January 18, 2011, 02:16:44 am »

I would be disappointed if hardly anyone made any offline multiplayer games for this compo.

I'd quite like to make a game that can be played across two (or more) laptops with wireless capability but without the need for a separate router or network. Does anyone know if that's feasible? (I'd prefer to use Unity or Flash for dev speed reasons...)

Jesus, that'd be so nifty. Any ideas, anyone?
Logged
TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW Email
« Reply #43 on: January 18, 2011, 03:44:35 am »

I'd quite like to make a game that can be played across two (or more) laptops with wireless capability but without the need for a separate router or network. Does anyone know if that's feasible?

Well, you could set up a Wireless ad hoc network and use a peer-to-peer connection.
Not having a server (or having the server hosted on one of the players machines) makes cheating easier, though.
Logged

bateleur
Level 10
*****



View Profile
« Reply #44 on: January 18, 2011, 04:25:34 am »

Well, you could set up a Wireless ad hoc network and use a peer-to-peer connection.
So having set up an ad-hoc network will (say) Windows just let my game start listening on any user port I feel like using and let clients send stuff to that port? If so then that's great, but it sounds a bit too good (and/or insecure) to be true.

Not having a server (or having the server hosted on one of the players machines) makes cheating easier, though.
But the great thing about playing face-to-face with friends like that is that unlike the internet my opponents are extremely unlikely to cheat. (And if they do it will only be because it's funny.)
Logged

TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW Email
« Reply #45 on: January 18, 2011, 04:36:43 am »

Well, you could set up a Wireless ad hoc network and use a peer-to-peer connection.
So having set up an ad-hoc network will (say) Windows just let my game start listening on any user port I feel like using and let clients send stuff to that port? If so then that's great, but it sounds a bit too good (and/or insecure) to be true.
Basically this, yes. They connect to your ad-hoc network like they would to any other network. You might need to set a static IP on the computer that hosts the ad-hoc network, but I'm not sure about this. Regarding security: It usually comes with a password like any other wireless network.

But the great thing about playing face-to-face with friends like that is that unlike the internet my opponents are extremely unlikely to cheat. (And if they do it will only be because it's funny.)
Yup. I only wanted to point it out for the unlikely case that it would be a concern to you but you haven't thought of it.
« Last Edit: January 18, 2011, 04:53:36 am by TobiasW » Logged

bateleur
Level 10
*****



View Profile
« Reply #46 on: January 18, 2011, 04:46:37 am »

OK, cool, thanks. I'll probably give this a try then!
Logged

Benjaminsen
Level 0
**


Games games games.... oh! And games!


View Profile Email
« Reply #47 on: January 18, 2011, 09:26:47 am »

This post might be to the interest of some of you Smiley
Logged
TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW Email
« Reply #48 on: January 18, 2011, 09:29:56 am »

Hey, welcome aboard Chris! Player.IO has quite a few mentions in this thread already Smiley
Logged

Benjaminsen
Level 0
**


Games games games.... oh! And games!


View Profile Email
« Reply #49 on: January 18, 2011, 09:30:57 am »

Hey, welcome aboard Chris! Player.IO has quite a few mentions in this thread already Smiley

Familiar faces everywhere, hey Tobias Smiley
Logged
Nugsy
Level 10
*****



View Profile
« Reply #50 on: January 18, 2011, 10:53:13 am »

This networking malarkey has me stumped, and i haven't even chosen an API yet!

I basically have four options:
1) RakNet
2) ENet
3) NetDog
4) SFML (See "network package" section)

I'm not sure which one to use, does anyone have any thoughts/opinions?
I am already using SFML for my io/rendering/audio etc. but i'm not sure how it's networking holds up.
Logged


Riley Adams
Level 5
*****


I don't actually use Ubuntu much...


View Profile
« Reply #51 on: January 18, 2011, 10:58:33 am »

This networking malarkey has me stumped, and i haven't even chosen an API yet!

I basically have four options:
1) RakNet
2) ENet
3) NetDog
4) SFML (See "network package" section)

I'm not sure which one to use, does anyone have any thoughts/opinions?
I am already using SFML for my io/rendering/audio etc. but i'm not sure how it's networking holds up.

I'm using enet, and it seems to work pretty well. I didn't want to use raw socket stuff since I'm lazy, but raknet seemed way too much, so enet seemed just right. The tutorial is a bit short (just snippets on how to do each thing with no actual complete working example code), but it's pretty self-explanatory.
Logged

Captain_404
Guest
« Reply #52 on: January 18, 2011, 11:38:32 am »

For those using GM, it looks like the Gang Garrison guys have an API built on their tech: http://forums.tigsource.com/index.php?topic=17052.0
Logged
Rob Lach
Level 10
*****



View Profile WWW Email
« Reply #53 on: January 18, 2011, 08:58:26 pm »

I didn't read the thread but I have been the network programmer for 2 MMOs for a class I took back in uni. I suppose I could answer questions in #tigirc directly. I'm thinking about writing up a short article about networking.


Edit:

Posting up some links I didn't spot in a skim through:

C++
Boost.asio (General): http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio.html
ACE (General): http://www.cs.wustl.edu/~schmidt/ACE.html
Zoidcom (Game Specific): http://www.zoidcom.com/

I've use all 3 of these. The most interesting is Zoidcom. If just want gamestate replication between clients in a p2p or dedicated server setup, all you do is tack on replication to the objects you want. Check out this specific link.

XNA also has a built in networking system which is extremely simple and they have pretty good samples of in the creators club.
« Last Edit: January 18, 2011, 09:13:06 pm by Pierog » Logged

Riley Adams
Level 5
*****


I don't actually use Ubuntu much...


View Profile
« Reply #54 on: January 18, 2011, 09:27:27 pm »

Hey, Pierog (or anyone else with networking experience), any advice on sending floating point numbers over a network, with endianness and whatnot?

I've read a lot of conflicting stuff (from just casting to an int and htonl-ing as with integers, to extracting the mantissa and exponent and sending them as ints... etc).
Logged

Sos
Level 8
***


I make bad games


View Profile WWW Email
« Reply #55 on: January 19, 2011, 02:25:54 am »

Hey, Pierog (or anyone else with networking experience), any advice on sending floating point numbers over a network, with endianness and whatnot?

I've read a lot of conflicting stuff (from just casting to an int and htonl-ing as with integers, to extracting the mantissa and exponent and sending them as ints... etc).

big-endian PCs are dead, unless you're making a MacOS 9 game or whatsoever
Logged

Riley Adams
Level 5
*****


I don't actually use Ubuntu much...


View Profile
« Reply #56 on: January 19, 2011, 02:32:44 am »

Hey, Pierog (or anyone else with networking experience), any advice on sending floating point numbers over a network, with endianness and whatnot?

I've read a lot of conflicting stuff (from just casting to an int and htonl-ing as with integers, to extracting the mantissa and exponent and sending them as ints... etc).

big-endian PCs are dead, unless you're making a MacOS 9 game or whatsoever

PowerPC was big-endian (or according to wikipedia I guess it could use both.. huh), and there are still a good deal of PPC Macs around (my high school had a bunch of PPC iMacs) Shrug... plus it's just kinda interesting for learning purposes...
Logged

Sos
Level 8
***


I make bad games


View Profile WWW Email
« Reply #57 on: January 19, 2011, 02:38:56 am »

Then , I guess, big-endians, being the minority, would need to handle conversion of network packets. The best you could do is stick to single bytes as much as possible.
Logged

mewse
Level 6
*



View Profile WWW
« Reply #58 on: January 19, 2011, 03:12:00 am »

This is an extremely pedantic point, and should probably only be read by people who are interested in networking "best practices" on the Internet, beyond the scope of this competition.  For all others, please skip down and just read the bolded section. 
 Beer!

Big-endian is the defined network format (and has been for decades).  For the general sanity of network interoperability programmers everywhere, all numbers should always be converted into big-endian format before being sent over a network, and then be converted back into the recipient's native format upon being received.

Yes, you can ignore that guidance and decide that for your own game's protocol, you're going to send everything in little-endian.  Just be aware that the rest of the Internet and all related standards go the other direction.

And certainly there are still a lot of big-endian machines out there.  Older Macs, lots of Linux/Unix boxes, XBox 360s, PS3s, etc.  If you're planning to continue doing network stuff, it's important to know how to interoperate with the network properly, and converting your data into the standard network byte order for transmission over the wire is an important part of that.

But on the other hand, if you're just making a once-off game for this competition and don't plan to have any cross-platform support in it, then absolutely don't worry about any of this, and just do whatever's fastest and easiest so you can focus on making your game awesome by the deadline.  :D


But if you really do want to know about how to handle floats on the Internet, between arbitrary computers which may have different endianness...  the floating point format is a standard that every modern computer uses (ignoring the byte ordering issue).  In order to transmit a float over the network according to the standards, you have to reorder the bytes into network byte order (big-endian), and then reorder them back again upon receipt, exactly the same as you do with integers.  However, there's a gotcha;  a byte-swapped floating point value can't legally be stored in a floating point register on the CPU.  The float will typically be invalidated (ie: written over with some form of NaN) if the CPU ever notices it in a register with its bytes swapped around.  So in order to byte-swap a float, you need to use a trick to keep the computer from viewing it as a float while it's byte-swapped. 

In C, here's how I'd do it:

float myValue = 2.0f;
uint32_t myPretendIntegerValue = *(uint32_t*)&myValue;
uint32_t myByteSwappedValueForSending = htonl(*myPretendIntegerValue);


Then to convert back on the other side:

uint32_t *myPretendIntegerValue;
uint32_t myReceivedByteSwappedValue = <whatever I received>;
myPretendIntegerValue = ntohl(myReceivedByteSwappedValue);
float myValue = *(float*)&myPretendIntegerValue;


At this point, 'myValue' now contains the transmitted floating point value.  At all times when the float was byte-swapped, its bytes were being stored inside a 32-bit integer, which kept it from ever being loaded into a float register and thereby becoming invalidated.  Yay, complicated!  But you'll find that there are no standard network functions for manipulating floats, so this is pretty much the best I've been able to come up with..
Logged
Sos
Level 8
***


I make bad games


View Profile WWW Email
« Reply #59 on: January 19, 2011, 03:15:22 am »

I like the bold section
Logged

Pages: 1 2 [3] 4 5
Print
Jump to:  

Theme orange-lt created by panic