FTP socket command read blocking on passive RETR get

Discussion in 'Java' started by Eric, Mar 4, 2005.

  1. Eric

    Eric Guest

    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
    Eric, Mar 4, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GM
    Replies:
    1
    Views:
    302
    John Machin
    Sep 9, 2006
  2. EuGeNe Van den Bulke

    poplib.retr doens't flag message as read

    EuGeNe Van den Bulke, Jun 19, 2007, in forum: Python
    Replies:
    3
    Views:
    307
    Gabriel Genellina
    Jun 20, 2007
  3. Serge Savoie
    Replies:
    4
    Views:
    256
    Serge Savoie
    Oct 1, 2008
  4. Hostile17

    Net::FTP and Passive mode problems

    Hostile17, Oct 20, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    183
    Sherm Pendley
    Oct 21, 2004
  5. justme

    perl Net::FTP vs Ncftp passive mode

    justme, Apr 18, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    170
    justme
    Apr 18, 2005
Loading...

Share This Page