# LAN game in Actionscript 3

I know this may be a somewhat dumb idea, but is there any "easy" resource that anyone can point me towards that shows how to set up a simple LAN connection in an Actionscript application? I only need to have two clients connected. Nothing extremely robust.

This is not an AIR application. It's for a game idea that I have that will need two players essentially. It will be local, so having each other's IP addresses will be an option. So no need to find or detect any IP addresses.

Thanks.

• You should try to add more details to your question. Is this an AIR application? Do you know the IP addresses of the clients or do they have to find themselves in the network? Also what do you use the connection for? – bummzack Feb 22 '12 at 8:17
• Sorry. Will add those edits. – Nicholas Feb 22 '12 at 8:58

You can't establish a direct connection between two flash-applications. You could write a server (for example in JAVA) which both flash clients connect to by using XMLSocket.

You can also do all your coding in Actionscript, but for that at least one of your applications needs to be an AIR application. There you can use ServerSocket and use Socket to connect with a client to the server.

So the simplest approach would be to write your Game as an AIR Application. Then you start one as the "server" (establish a ServerSocket) and connect from the other application to the IP address of the server.

Update: Here's an article that will guide you through the basics of ServerSocket and Socket.

• This is an old answer but I think it's wrong: NetConnection and NetGroup can be used for p2p communication between 2 flash apps (no need for air). I've corrected @Dovyski links, I think his answer is the most relevant. – chadiik Oct 31 '13 at 21:12

You can embed an socket server in your game or create a side application that you will use as server. It is fairly simple to do with AIR: http://www.adobe.com/devnet/air/flex/articles/creating_socket_server.html

another option is to use p2p connection with flash using cirrus: http://labs.adobe.com/technologies/cirrus/