FTP socket command read blocking on passive RETR get

E

Eric

Hi all,

I've been developing some FTP routines for a handheld device, using the
java microedition (J2ME). 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.

What I expect, after sending the RETR command, is to read the command
reply (150 response), and then read the data socket to get the data.

My problem is that the attempt to read the command socket after sending
the RETR command, blocks and 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), then go
back and finish reading the data socket for all the data. This is a
kludgy solution, but works generally.

I've have my socket connection encapsulated in a class; each connection
is its own instanciated class. Furthermore, each is a runnable class
and is running in its own thread in a continious sleep/wake cycle
waiting for action commands (read/write to socket) from the main
thread. I've done this to specifically prevent any blocking problems.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top