Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8744345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:49:36+00:00 2026-06-13T11:49:36+00:00

My problem is that I’m creating a FTP client, and so far its working

  • 0

My problem is that I’m creating a FTP client, and so far its working flawlessly besides one minor detail, that keeps bugging me.
I need to know how many lines the FTP welcome message spans over… And this cannot be acceptable!

    private Socket connection;
    private PrintWriter outStream;
    private Scanner inStream;

public void InitiateConnection() throws IOException 
{
    log.Info(this, "Initiating connection to host: " + host + ":" + port);
    connection = new Socket(host, port);
    log.Info(this, "Connection initiated.");
    outStream = new PrintWriter(connection.getOutputStream(), true);
    inStream = new Scanner(connection.getInputStream());
    Listen();
    Listen();    
    Listen();
}

public String Listen() throws IOException
{
    if(connection == null)
        throw new IOException("Connection not initiated yet");
    String response = inStream.nextLine();
    log.Info(this, "Response: " + response);
    return response;
}

This is the simple setup, I have left out all other code, as it doesn’t have anything to do with my problem.

I have tried multiple things to try to achieve this.
Failed Solution 1:

String response = "";
while(response != null)
    Listen();

Failed Solution 2:

while(connection.getInputStream().available > 0)
    Listen();

And countless others… But either it doesn’t work, or the methods block and wait for new input. I have even tried with a timeout, but that doesn’t work flawlessly either, its not a proper solution to this problem…

I need to be able to get the entire welcome message from the FTP server, without knowing the amount of lines…
So I can both get this:

Response:   220-FileZilla Server version 0.9.39 beta
Response:   220-written by Tim Kosse (Tim.Kosse@gmx.de)
Response:   220 Please visit http://sourceforge.net/projects/filezilla/

And this:

Response:   220-FileZilla Server version 0.9.40 beta
Response:   220 Welcome to Andrés FTP Server
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:49:37+00:00Added an answer on June 13, 2026 at 11:49 am

    If you have a close look at the messages, you see that all but the last lines have a - behind the status code. The last line has a , however, indicating, well, the last line.

    You can read that in RFC 959, section 4.2:

    Thus the format for multi-line replies is that the first line
    will begin with the exact required reply code, followed
    immediately by a Hyphen, “-” (also known as Minus), followed by
    text. The last line will begin with the same code, followed
    immediately by Space , optionally some text, and the Telnet
    end-of-line code.

    There is nothing said about the 2nd to second-last line, but it is logical that they have the same format as the 1st one.


    Update: The FTP protocol seems to be badly documented, but I found another reference stating the same as me above:

    The TCP/IP Guide mentions that

    It is possible for a reply to contain more than one line of text. In this case, each line starts with the reply code, and all lines but the last have a hyphen between the reply code and the reply text, to indicate that the reply continues. The last line has a space between the reply code and reply text, just like a single-line reply. This facility is often used to provide additional response information after a user logs in, via the 230 reply code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that I'm working on for quite some time now. I
One problem that I have frequently run into lately is the problem of my
One problem that I come across regularly and yet don't have a solution to
One problem that I have with emacs is that it doesn't seem to handle
One problem that I am facing is having many queries with similar select statements
Simple problem that I can't figure out... How can I print a '%' character
The problem that I have is somehow very specific. I have to implement a
Here is a problem that has been bothering me a lot about Python, I
Im currently facing the problem that when i try to set focus on some
Seems to be a problem that many people have, but all the answers I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.