<p>Sorry for the subject line sounding like an even nerdier Harry Potter title.</p>

<p>I'm trying to use AS3's Socket class to write a simple FTP program to export as an AIR app in Flex Builder 3.  I'm using an FTP server on my local network to test the program.  I can successfully connect to the server (the easy part) but I can't send any commands.  I'm pretty sure that you have to use the ByteArray class to send these commands but there's some crucial piece of information that I'm missing apparently.  Does anyone know how to do this?  Thanks!
Dave</p>

[{'answer_id': 64810, 'author': 'Antti', 'author_id': 6037, 'author_profile': 'https://Stackoverflow.com/users/6037', 'pm_score': 0, 'selected': False, 'text': '<p>We will need more info to resolve this.. What you\'re saying here appears correct to me. You\'re using the Socket class to send data though, not ByteArray.</p>\n\n<p>Are you sure data is not being sent? How are you receiving the response? It may be that it\'s working fine but you\'re just not aware of it? As i said, tell us more about what you\'re doing..</p>\n\n<p>Lee Brimelow has a <a href="http://gotoandlearn.com/play?id=69" rel="nofollow noreferrer">screencast on gotoAndLearn</a> of writing an POP3 client. It\'s essentially the same of what you\'re doing so take a look.</p>\n'}, {'answer_id': 74805, 'author': 'Antti', 'author_id': 6037, 'author_profile': 'https://Stackoverflow.com/users/6037', 'pm_score': 0, 'selected': False, 'text': "<p>Are you 100% sure the syntax is correct? I know with HTTP you'll have to an include extra linebreak after the request for it to go through. Without it you'll get nothing back. Not sure how it is with FTP though.</p>\n"}, {'answer_id': 161955, 'author': 'Darron', 'author_id': 22704, 'author_profile': 'https://Stackoverflow.com/users/22704', 'pm_score': 0, 'selected': False, 'text': '<p>The FTP standard requires CRLF at the end of commands.  Try using "\\r\\n" in place of the "\\n" in your example.</p>\n'}, {'answer_id': 223908, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>You must serve the CrossDomain Policy File from your FTP server in order to conect correctly.</p>\n'}, {'answer_id': 289252, 'author': 'seanalltogether', 'author_id': 26986, 'author_profile': 'https://Stackoverflow.com/users/26986', 'pm_score': 0, 'selected': False, 'text': '<p>From what I\'ve gathered, you have to send each command one at a time and validate the response before moving on. You should be getting something back against ProgressEvent.SOCKET_DATA</p>\n\n<p>Try just this and see what you get in response.</p>\n\n<pre><code>socket.writeUTFBytes("USER "+user+"\\n"); socket.flush();\n</code></pre>\n\n<p>You would then read the response out like this.</p>\n\n<pre><code>var response:String = mySocket.readUTFBytes(mySocket.bytesAvailable);\n</code></pre>\n'}, {'answer_id': 437669, 'author': 'spender', 'author_id': 14357, 'author_profile': 'https://Stackoverflow.com/users/14357', 'pm_score': 2, 'selected': False, 'text': '<p>The FTP protocol predates UTF encoding. Switch to ANSI/ASCII for better results. If you do opt for writeMultiByte instead of writeUTFBytes, be aware that it is buggy in linux. <a href="http://www.flexiblefactory.co.uk/flexible/?p=75" rel="nofollow noreferrer">Here\'s</a> one way around it.</p>\n<p>There\'s another question <a href="https://stackoverflow.com/questions/285290/trying-to-send-an-http-request-over-sockets">here</a> where the line ending turns out to be the culprit, so make sure that you get it right (as suggested above).</p>\n<p>As said before, if this is running from the web, all socket connections will require a crossdomain policy, but this is NOT file based over HTTP. Recent changes to the security rules mean that any socket based connection must first get a crossdomain from a policy server hosted on port 843 of the target host.</p>\n<p>Quoting from Adobe:</p>\n<blockquote>\n<p>A SWF file may no longer make a socket connection to its own domain without a socket policy file. Prior to version 9,0,115,0, a SWF file was permitted to make socket connections to ports 1024 or greater in its own domain without a policy file.</p>\n<p>HTTP policy files may no longer be used to authorize socket connections. Prior to version 9,0,115,0, an HTTP policy file, served from the master location of /crossdomain.xml on port 80, could be used to authorize a socket connection to any port 1024 or greater on the same host.</p>\n</blockquote>\n<p>Essentially, what this means is that you must be in control of the target FTP host, and install supplementary software on it to get this working.</p>\n'}, {'answer_id': 1450755, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Read <a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS1EFE2EDA-026D-4d14-864E-79DFD56F87C6.html" rel="nofollow noreferrer">this link</a> too and maybe it can be useful <a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cf7.html" rel="nofollow noreferrer">this one</a> too.</p>\n\n<p>The first one is about policy files and the second is an example of a TELNET (so, no FTP here) client.</p>\n'}, {'answer_id': 1709499, 'author': 'DF.', 'author_id': 207957, 'author_profile': 'https://Stackoverflow.com/users/207957', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve been able to get an FTP client working in a browser, but it\'s buggy.  I had to get a listener running on port 843 to server the policy file so that Flash would be allowed to connect and transfer data.  Then, I had to figure out how FTP actually works:</p>\n\n<p>You have to open 2 sockets: a command socket and a data socket.  The command socket is where you send your USER, PASS, CWD, and STOR commands.  The data socket is where you write your ByteArray data to.  Sending the PASV command will tell you what port your data socket must connect to.</p>\n\n<p>Where it is buggy is on Mac, in both Safari and FF, when I call the "socket.close()" command, the server socket actually closes.  On Windoze, it does not.  This is a huge problem because the Event.CLOSE event is not fired until the SERVER closes the connection.  This is in the livedocs.</p>\n\n<p>This is where I\'m at.  I have no idea why it would work flawlessly on Mac and then be completely busted in 3 different browsers on Windows.  The only thing I can come up with is that it\'s either something in my Windows configuration that\'s preventing proper communication with the server, or it\'s the Window Flash player that\'s causing the problem.</p>\n\n<p>Any thoughts?</p>\n'}]
['https://Stackoverflow.com/questions/63038', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7478/']