Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.3k views
in Java FTP by
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

3 Answers

0 votes
by (162k points)
You have to create the data socket before you can send RETR. You shouldn't have to read from it.

Have you tried compiling edtFTPj on JSME? We haven't, but it wouldn't surprise me if it works ok (might have to chop out a bit of code). That'd be a whole lot easier than rolling it all yourself.

I should expect to be able to freely read the command response to the RETR before starting to read the data socket, right?
0 votes
by
Yes, I have tried to compile it via J2ME. It is not going to be easy. There are plenty of packages and classes that will need to be "replaced" with create-your-own, or programmed around the usage of them. It would be a project in itself to rebuild edtFTP. Not sure who would have a need to have general ftp abilities to download files to a handheld device limited memory), however, using it to manage/direct a passive server1 to server2 ftp transfer controlled by a handheld client might be of interest?

I am quite sure that I am connecting the data socket first, but perhaps its not pushing thru to the server to let it know the connections be made. I will investigate that further. Thanks.

Regards,
Eric


You have to create the data socket before you can send RETR. You shouldn't have to read from it.

Have you tried compiling edtFTPj on JSME? We haven't, but it wouldn't surprise me if it works ok (might have to chop out a bit of code). That'd be a whole lot easier than rolling it all yourself.

I should expect to be able to freely read the command response to the RETR before starting to read the data socket, right?
0 votes
by (220 points)
Hi, I would to know if you have managed to work edtftp on j2me/cldc.

Thanks in advice.
and happy new year :)

Categories

...