Hello,
Can I post a question on J2ME socket FTP programming here? I've examined the edtftpj source for the design and am implementing what I can.
I've been developing some FTP routines for a handheld device, using the java microedition (J2ME) in MIDP 2.0/CLDP platform. The FTP protocol is not support natively by J2ME sockets, hence you have to roll your own. I have lots of it working fine, so this isn't a "how to" question. My problem is the implemetation.
After socket creation and connect/login I can freely send commands and receive responses. I understand and can successfully create the second data socket needed for a data connection. I successfully interpret the PASV response to determine the server port to connect to. This is all ok.
My problem is that the attempt to read the command socket after sending the RETR command, times out. I've discovered that the data socket is available, however. I've also discovered that if I read just one byte from the data socket, I can then go back to the command socket and read the 150 response (its not blocked anymore), and then go back and finish reading the data socket for all the binary data. This is a kludgy solution, but works generally.
Each socket connection is its own instanticated/runnable class running on its own thread in a continious sleep/wake loop. I've done this to specifically prevent blocking.
I should expect to be able to freely read the command response to the RETR before starting to read the data socket, right?
Anyone have ideas why the command socket would block until at least one byte was read from the data socket. Then the command socket unblocks.
Thanks for reading this far.
Cheers,
Eric