2 Attachment(s)
[RESOLVED] Need some help with simple socket server
I've created a simple Java server app and an AS3 client. Basically AS3 client only connects to the server on localhost:4444 using XMLSocket.
Java server runs great. It listens to the port 4444 and even reacts to my as3 client connection.
http://s47.radikal.ru/i118/1008/6c/94074a0860b4.jpg
AS3 client is supposed to create a new TextField and "Got it" text to it on connection event. That's where the problem appears.
I can see it tries to get a policy file. But I have this file placed into the same folder with my Java server:
http://i068.radikal.ru/1008/3a/5168302e1b52.jpg
Here's its source:
Quote:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
Here's the source of the testApp.jar
Actionscript Code:
package com.konstantin;
import java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) throws IOException {
System.out.println("Welcome to Server side");
BufferedReader in = null;
PrintWriter out= null;
ServerSocket servers = null;
Socket fromclient = null;
// create server socket
try {
servers = new ServerSocket(4444);
} catch (IOException e) {
System.out.println("Couldn't listen to port 4444");
System.exit(-1);
}
try {
System.out.print("Waiting for a client...");
fromclient = servers.accept();
System.out.println("Client connected");
} catch (IOException e) {
System.out.println("Can't accept");
System.exit(-1);
}
in = new BufferedReader(new
InputStreamReader(fromclient.getInputStream()));
out = new PrintWriter(fromclient.getOutputStream(),true);
String input;
System.out.println("Wait for messages");
while ((input = in.readLine()) != null) {
if (input.equalsIgnoreCase("exit")) break;
out.println("S ::: "+input);
System.out.println(input);
}
out.close();
in.close();
fromclient.close();
servers.close();
}
}
The source for Client can be found in attachments.
What am I doing wrong? :confused: