Multiplayer Flash Game Help!

Hi there, I'm trying to create a multiplayer flash game using sockets, but I dont know how I would send and recieve the _x and the _y coordinates of flash.Thanks for any help!
[190 byte] By [Katocana] at [2007-10-2 20:14:10]
# 1
What is your question about Java? Are you going to write Flash game using Java? I'm afraid it's impossible. :)
Michael.Nazarov@sun.coma at 2007-7-13 22:56:21 > top of Java-index,Archived Forums,Socket Programming...
# 2

No, what I wanna do is make a java XMLSocket server.

I followed this tutorial http://www.gotoandplay.it/_articles/2003/12/xmlSocket.php but it only shows you how to send and recieve text but I want to send and recieve the _x and _y of every player.

Heres the code in the tutorial:

import java.io.*;

import java.net.*;

public class simpleServer

{

public static void main(String args[])

{

// Message terminator

char EOF = (char)0x00;

try

{

// create a serverSocket connection on port 9999

ServerSocket s = new ServerSocket(9999);

System.out.println("Server started. Waiting for connections...");

// wait for incoming connections

Socket incoming = s.accept();

BufferedReader data_in = new BufferedReader(

new InputStreamReader(incoming.getInputStream()));

PrintWriter data_out = new PrintWriter(incoming.getOutputStream());

data_out.println("Welcome! type EXIT to quit." + EOF);

data_out.flush();

boolean quit = false;

// Waits for the EXIT command

while (!quit)

{

String msg = data_in.readLine();

if (msg == null) quit = true;

if (!msg.trim().equals("EXIT"))

{

data_out.println("You sayed: <b>"+msg.trim()+"</b>"+EOF);

data_out.flush();

}

else

{

quit = true;

}

}

}

catch (Exception e)

{

System.out.println("Connection lost");

}

}

}

Thanks for any help.

Katocana at 2007-7-13 22:56:21 > top of Java-index,Archived Forums,Socket Programming...
# 3

Look like this is code of simple Echo-like server. There is nothing about game or coordinates of any kind. All you can do is send to server string like: "x?" and recive answer like "x=100". Is this a game? :)

Well, code should be followed:

import java.io.*;

import java.net.*;

public class simpleServer

{

public static void main( String[] args )

{

// Message terminator

char EOF = ( char )0x00;

try

{

// create a serverSocket connection on port 9999

ServerSocket s = new ServerSocket( 9999 );

System.out.println( "Server started. Waiting for connections..." );

// wait for incoming connections

int x = 100, y = 100;

while( true )

{

Socket incoming = s.accept( );

BufferedReader data_in = new BufferedReader(

new InputStreamReader(incoming.getInputStream( ) )

);

PrintWriter data_out = new PrintWriter(incoming.getOutputStream());

data_out.println( "Welcome! type EXIT to quit." + EOF );

data_out.flush( );

boolean quit = false;

// Waits for the EXIT command

while( !quit )

{

String msg = data_in.readLine();

if( null == msg)

quit = true;

if( msg.trim( ).equals( "X?" ) )

{

data_out.println( "X = " + x + EOF );

data_out.flush( );

}

else

if( msg.trim( ).equals( "Y?" ) )

{

data_out.println( "Y = " + y +EOF );

data_out.flush( );

}

else

if( msg.trim( ).equals( "X+" ) )

{

x++;

data_out.println( "X increased" + EOF );

data_out.flush( );

}

else

if( msg.trim( ).equals( "Y+" ) )

{

y++;

data_out.println( "Y increased" + EOF );

data_out.flush( );

}

else

if( msg.trim( ).equals( "X-" ) )

{

x--;

data_out.println( "X decreased" + EOF );

data_out.flush( );

}

else

if( msg.trim ().equals( "Y-" ) )

{

y--;

data_out.println( "Y decreased" + EOF );

data_out.flush( );

}

else

if( msg.trim( ).equals( "EXIT" ) )

{

data_out.println( "Bye!" + EOF );

data_out.flush( );

quit = true;

}

else

{

data_out.println( "You sayed: <b>" + msg.trim( ) + "</b>" + EOF );

data_out.flush( );

}

}

incoming.close( );

}

}

catch( Exception e )

{

System.out.println( "Connection lost, shutting down..." );

}

}

}

Michael.Nazarov@sun.coma at 2007-7-13 22:56:21 > top of Java-index,Archived Forums,Socket Programming...
# 4
Hey thanks for the reply and the code that cleared things up alot, and yup this is for a game :).
Katocana at 2007-7-13 22:56:21 > top of Java-index,Archived Forums,Socket Programming...