Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to abort the connection for CTRL-C in FTP in java programming on UNIX

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to abort the connection for CTRL-C in FTP in java programming on UNIX

    Hi Friends,

    I have a clinet and server socket programming.

    and the client is writting some data to server. It has to stop writting and throw IOException when I enter CTRL-C

    when I do the same with windows and enters CTRL-C in between I get IOException and connection is lost.
    For the same programme, I dont get any exception If I run on Unix.


    Can anybody please answer me why there is no exception when I enter CTRL-C on Unix & what is the solution for this.



    A quick response is appricated and thanks in adavance.


  2. #2
    Member Abhilash's Avatar
    Join Date
    Jun 2014
    Location
    Kolkata, West Bengal, INDIA
    Posts
    108
    My Mood
    Busy
    Thanks
    5
    Thanked 10 Times in 10 Posts

    Lightbulb Re: How to abort the connection for CTRL-C in FTP in java programming on UNIX

    Welcome mantry to the forum. Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    You can Introduce yourself at Member Introductions.

    Thank you.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to abort the connection for CTRL-C in FTP in java programming on UNIX

    Show the exception code that is supposed to capture CTRL-C to interrupt the current process.

  4. #4
    Junior Member
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to abort the connection for CTRL-C in FTP in java programming on UNIX

    while ((block = queue.next()) != null) {
    int count = block.getUsed();
    writer.write(block.getData(), 0, count);
    bytes += count;
    block.free(blocks);
    block = null;
    }

    } catch (IOException ioe) {
    if (output instanceof DataSource) {
    ((DataSource) output).failed(ioe.getMessage());
    } else if (output instanceof SocketOutputStream) {
    ((SocketOutputStream) output).drop(true);
    }

    throw ioe;

    } finally {
    reader.reset();
    writer.release();

    if (block != null) {
    block.free(blocks);
    }



    when ever I enter CTRL-C, It should throw IOException

Similar Threads

  1. Read a binary unix file with Java?
    By dunamase3 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 24th, 2014, 09:36 AM
  2. [SOLVED] FileNotFoundException on ftp connection
    By hdty in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 10th, 2013, 07:39 PM
  3. Replies: 0
    Last Post: March 27th, 2012, 08:00 AM
  4. Scanning large FTP directories with apache.commons.net.ftp
    By daniel_el in forum Java Theory & Questions
    Replies: 3
    Last Post: February 10th, 2012, 06:40 AM
  5. simple ftp server and ftp client
    By simontkk2005 in forum Java Networking
    Replies: 4
    Last Post: January 26th, 2011, 10:29 AM

Tags for this Thread