I started on a really simple one in python, which runs great on osx...

bedar.net/simpleChatServer.zip







On Nov 20, 2005, at 3:32 PM, Michael Bianco wrote:

Hello,
Does anybody have a XMLSocket Server that works on os x?
I cant seem to get a connection working between the SWF and my java server.

Heres my java server:
---------------------------------------------------------------------- -----------------------------------
import java.net.*;
import java.io.*;

public class serverTest {
        public static void main(String[] args) {
                System.setErr(System.out);
                
                try {
                        int maxConnections = 100;
                        Socket[] clients = new Socket[maxConnections];
                        
                        printAvailIp();
                        
                        ServerSocket servSock = new ServerSocket(2500, 0,
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()) [0]);
                        
                        while(true) {
                                Socket newSock = servSock.accept();
                                newSock.setTcpNoDelay(true);
                                
                                System.out.println("Got connection!");
                                printStatus(newSock);
                        }
                }
                
                catch (Exception a) {
                        System.out.println(a);
                }
        }
        
        private static void printStatus(Socket sock) {
                System.out.println("Connected: "+ sock.isConnected());
                System.out.println("Is closed: "+ sock.isClosed());
        }
        
        private static void printAvailIp() {
                try {
                        InetAddress[] ips =
InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
                        for(int a = 0; a < ips.length; a++) {
                                System.out.println(ips[a]);
                        }
                }
                
                catch (Exception a) {
                        System.out.println(a);
                }
        }
}
---------------------------------------------------------------------- -----------------------------------

Heres my code on the client (flash side):
---------------------------------------------------------------------- --------------------
class mainEntryPoint {
        static function main() {
                XML.prototype.ignoreWhite = true;

                setInterval(tryConnect, 1000);
                //tryConnect();
        }
        
        static function tryConnect() {
                trace("Try to Connect");
                
                var socket = new XMLSocket();
                
                socket.onConnect = function(success:Boolean) {
                        trace("connected! "+ success);
                }
                
                socket.onData = function() {
                        trace("got data");
                }
                
                socket.onClose = function() {
                        trace("closing");
                }
                
                socket.onXML = function(src:XML) {
                        trace("Got XML!"+src);
                }
                
                trace("Inital Connect: "+ socket.connect("192.168.0.4", 2500));
        }
}
---------------------------------------------------------------

HEre the output i get from the flash SWF:
Inital Connect: true
connected! false

Nomatter what i do i cant get it to actually connect to the server. Any ideas?
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to