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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:28:19+00:00 2026-06-01T10:28:19+00:00

I am writing some java TCP/IP networking code ( client – server ) in

  • 0

I am writing some java TCP/IP networking code ( client – server ) in which I have to deal with scenarios where the sends are much faster than the receives , thus blocking the send operations at one end. ( because the send and recv buffers fill up ). In order to design my code , I wanted to first play around these kind of situations first and see how the client and servers behave under varying load. But I am not able to set the parameters appropriately for acheiving this back pressure. I tried setting Socket.setSendBufferSize(int size) and Socket.setReceiveBufferSize(int size) to small values – hoping that would fill up soon, but I can see that send operation completes without waiting for the client to consume enough data already written. ( which means that the small send and recv buffer size has no effect )

Another approach I took is to use Netty , and set ServerBootstrap.setOption("child.sendBufferSize", 256);, but even this is of not much use. Can anyone help me understand what I am doing wrong /

  • 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-01T10:28:21+00:00Added an answer on June 1, 2026 at 10:28 am

    The buffers have an OS dependent minimium size, this is often around 8 KB.

    public static void main(String... args) throws IOException, InterruptedException {
        ServerSocketChannel ssc = ServerSocketChannel.open();
        ssc.bind(new InetSocketAddress(0)); // open on a random port
        InetSocketAddress remote = new InetSocketAddress("localhost", ssc.socket().getLocalPort());
        SocketChannel sc = SocketChannel.open(remote);
        configure(sc);
        SocketChannel accept = ssc.accept();
        configure(accept);
    
        ByteBuffer bb = ByteBuffer.allocateDirect(16 * 1024 * 1024);
        // write as much as you can
        while (sc.write(bb) > 0)
            Thread.sleep(1);
        System.out.println("The socket write wrote " + bb.position() + " bytes.");
    }
    
    private static void configure(SocketChannel socketChannel) throws IOException {
        socketChannel.configureBlocking(false);
        socketChannel.socket().setSendBufferSize(8);
        socketChannel.socket().setReceiveBufferSize(8);
    }
    

    on my machine prints

    The socket write wrote 32768 bytes.
    

    This is the sum of the send and receive buffers, but I suspect they are both 16 KB

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

Sidebar

Related Questions

I have a file which I write some java objects. After writing, sometimes I
Suppose I'm writing some environment which execute clients code (Java). Clients send jar with
I'm writing RTSP server and have some problems. I'm using VLC as client. Server
I am having trouble writing some Java code, which will create a container/folder in
I am writing some Java code that authenticates to Active Directory using SASL GSSAPI.
I'm writing some Java code that deals with Chinese characters, and I got some
I'm writing some java code that's supposed to parse csv files with different column
How would I go about writing some code to allow access to a Java
I have some experience writing web applications in Java for class projects. My first
I'm writing some code in Java that needs to show file chooser and alert

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.