Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 389

Programming actionscript 3.0
Table of Contents

Advertisement

{
socket = new ServerSocket(port);
incoming = socket.accept();
readerIn = new BufferedReader(new
InputStreamReader(incoming.getInputStream()));
printOut = new PrintStream(incoming.getOutputStream());
printOut.println("Enter EXIT to exit.\r");
out("Enter EXIT to exit.\r");
boolean done = false;
while (!done)
{
String str = readerIn.readLine();
if (str == null)
{
done = true;
}
else
{
out("Echo: " + str + "\r");
if(str.trim().equals("EXIT"))
{
done = true;
}
}
incoming.close();
}
}
catch (Exception e)
{
System.out.println(e);
}
}
private void out(String str)
{
printOut.println(str);
System.out.println(str);
}
}
Save the document to your hard disk as SimpleServer.java and compile it using a Java
compiler, which creates a Java class file named SimpleServer.class.
You can start the XMLSocket server by opening a command prompt and typing
. The SimpleServer.class file can be located anywhere on your local computer
SimpleServer
or network; it doesn't need to be placed in the root directory of your web server.
If you're unable to start the server because the files are not located within the Java
classpath, try starting the server with
java -classpath . SimpleServer
java
.
Socket connections
389

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents