XML Socket Problem

Hi guys can someone help me with this I’ve been looking at it for a while now and can’t see where I’m going wrong. All I need to do is get my file to connect to the socket but when I try it nothing happens I don’t even get the failed to connect to socket message. If someone can spot where I’m going wrong I would be most grateful. I know the server side code is correct so it has to be my actionscript.



import mx.transitions.easing.*;
import mx.transitions.Tween;

// Create a new XMLSocket
var ClientSock = new XMLSocket();

// THe onConnect function is an event handler fired when the XMLSocket attempts to connect to the remote server
ClientSock.onConnect = function(success)
{
    if ( success )
    {
        trace("Successfully Connected to socket");
        
    }
    else
    {
        trace("Failed to connect to socket");
    }
}


//Fuction sends message when connection is closed.
ClientSock.onClose = function()
{
    trace("<b>Server connection lost</b>");
}
// This function handles XML messages and is fired with the flash application recieves and XML message from the server, the paramater 'doc' is the XML document
ClientSock.onXML = function(doc)
{
    trace("Recieved following XML from Server");
    trace( doc.toString());
}

// Example of function that sends XML message to remote server
function Test()
{
    msg = new XML();
    msgdata = msg.createElement("Admin");
    msgdata.attributes.Command = "debug";
    msg.appendChild( msgdata );
    ClientSock.send( msg );
    
}

// Ensure socket is closed first
ClientSock.Close();
// Connect to remote Server
ClientSock.connect("82.109.164.188", 12345 );


Thanks in advance.