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 6819689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:20:11+00:00 2026-05-26T21:20:11+00:00

I write a client-server application which will be sending an .xml file from the

  • 0

I write a client-server application which will be sending an .xml file from the client to the server. I have a problem with sending large data. I notice that the server can get at most 1460 bytes. When I send a file with more than 1460 bytes the server gets only first 1460 bytes and nothng more. In effect I get uncompleted file. Here is my code:

client send:

public void sendToServer(File file) throws Exception
{
    OutputStream output = sk.getOutputStream();     

    FileInputStream fileInputStream = new FileInputStream(file);
    byte[] buffer = new byte[1024*1024];
    int bytesRead = 0;

    while((bytesRead = fileInputStream.read(buffer))>0)
    {
        output.write(buffer,0,bytesRead);
    }

    fileInputStream.close();
}

server get:

public File getFile(String name) throws Exception
{
    File file=null;

    InputStream input = sk.getInputStream();

    file = new File("C://protokolPliki/" + name);
    FileOutputStream out = new FileOutputStream(file);

    byte[] buffer = new byte[1024*1024];

    int bytesReceived = 0;

    while((bytesReceived = input.read(buffer))>0) {
        out.write(buffer,0,bytesReceived);
        System.out.println(bytesReceived);
        break;
    }

    return file;
}

Do anyone know what is wrong with this code? Thanks for any help.

EDIT:

Nothing help :(. I google about that and I think its may connected with TCP MSS with is equal 1460 bytes.

  • 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-05-26T21:20:11+00:00Added an answer on May 26, 2026 at 9:20 pm

    Make sure you call flush() on the streams.


    A passerby asks: isn’t close() enough?

    You linked to the docs for Writer, and the info. on the close() method states..

    Closes the stream, flushing it first. ..

    So you are partly right, OTOH, the OP is clearly using an OutputStream and the docs for close() state:

    Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

    The close method of OutputStream does nothing.

    (Emphasis mine.)

    So to sum up. No, calling close() on a plain OutputStream will have no effect, and might as well be removed by the compiler.

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

Sidebar

Related Questions

I'm trying to write a client-server application in Java with an XML-based protocol. But
I would like to write an application which will stream data at 2400 baud
I have a need to write an client-server application where a tiny server rests
I start to write a client - server application using .net (C#) for both
I try to write a simple client/server application (all application is a bluetooth service
I am trying to write a unit test for a client server application. To
I am new to java NIO. I have to write a simple server client
I need to write a Java client application which, when given the below URL,
I'm writing web application where I need to push data from server to the
I am new to appengine. I will write application which consist of two parts.

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.