Java API Tutorial - Java Socket.setSendBufferSize(int size)








Syntax

Socket.setSendBufferSize(int size) has the following syntax.

public void setSendBufferSize(int size)   throws SocketException

Example

In the following code shows how to use Socket.setSendBufferSize(int size) method.

import java.net.Socket;
//from w  w  w .  j  ava2  s.com
public class Main {
  public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setSendBufferSize(1000);
    System.out.println(client.getSendBufferSize());

    client.close();
  }
}

The code above generates the following result.