How to set the buffer size of TCP/IP connection?

How to set the buffer size of TCP/IP connection?

Post by Carfield Yi » Sat, 25 Mar 2000 04:00:00



I know that when I writing TCP/IP socket program in C, the system will
allocate a buffer to hold the data to be sent and received, how can I
check the size of this buffer?, how can I change the size of this buffer
also?
 
 
 

How to set the buffer size of TCP/IP connection?

Post by Tony R. Benne » Sat, 25 Mar 2000 04:00:00




Quote:>I know that when I writing TCP/IP socket program in C, the system will
>allocate a buffer to hold the data to be sent and received, how can I
>check the size of this buffer?, how can I change the size of this buffer
>also?

I believe your actual question is probably "Can I tell how much data is
waiting to be read?"... And the answer is no.

But as to the question you actually posed...assuming we're talking about
STREAM sockets and not UDP...

When you 'write()' or 'send()' data is "passed" to TCP/IP.
TCP/IP is responsible for delivering this data to the peer.
TCP/IP may break up the data into multiple "transmissions" and
reassemble it on the Peer's side, in the proper sequence.

As to the buffer size, there is a "send" buffer and a "receive" buffer
on each side.  Whose size you can determine with getsockopt() &
SO_SNDBUF/SO_RCVBUF...and whose size you can modify with setsockopt().

When you do a write(), if there is sufficient unused room in your buffer
to place your data, then it is copied into the send buffer and control
is passed back to your program.  If on the other hand there is
insufficient room in your send buffer then your program is put to sleep
until enough data has been sent to the peer to free up enough space in
your send buffer to copy your data in.  At that time control is then
passed back to your program.

I suggest reading W. Richard Stevens "Unix Network Programming" volume I.
Don't program sockets without it!!!

HTH,
Tony

--



 
 
 

How to set the buffer size of TCP/IP connection?

Post by Ian Collin » Sat, 25 Mar 2000 04:00:00



> I know that when I writing TCP/IP socket program in C, the system will
> allocate a buffer to hold the data to be sent and received, how can I
> check the size of this buffer?, how can I change the size of this buffer
> also?

See man getsockopt and the options SO_RCVBUF ans SO_SNDBUF.

    Ian

 
 
 

How to set the buffer size of TCP/IP connection?

Post by Carfield Yi » Tue, 28 Mar 2000 04:00:00


Can you please kindly give me an example, I don't know how to use.
From the manual, I know the structure is:
 setsockopt(int socketname, int level, int SO_RCVBUF/SO_SNDBUF, const char
*optval, int optlen);
the what is level of 'level', 'optval' and 'optlen'? it seen that I should put
'32768' in the value of optval pointer, but I don't know why it is character
pointer.


> > I know that when I writing TCP/IP socket program in C, the system will
> > allocate a buffer to hold the data to be sent and received, how can I
> > check the size of this buffer?, how can I change the size of this buffer
> > also?

> See man getsockopt and the options SO_RCVBUF ans SO_SNDBUF.

>     Ian

 
 
 

How to set the buffer size of TCP/IP connection?

Post by Tony R. Benne » Tue, 28 Mar 2000 04:00:00




 >Can you please kindly give me an example, I don't know how to use.
 >From the manual, I know the structure is:
 > setsockopt(int socketname, int level, int SO_RCVBUF/SO_SNDBUF, const char
 >*optval, int optlen);
 >the what is level of 'level', 'optval' and 'optlen'? it seen that I should put
 >'32768' in the value of optval pointer, but I don't know why it is character
 >pointer.
 >
 >

 >>
 >> > I know that when I writing TCP/IP socket program in C, the system will
 >> > allocate a buffer to hold the data to be sent and received, how can I
 >> > check the size of this buffer?, how can I change the size of this buffer
 >> > also?
 >>
 >> See man getsockopt and the options SO_RCVBUF ans SO_SNDBUF.
 >>
 >>     Ian
 >

      int max_msg_size=0;
      int sock;
      size_t size_of_buf  = sizeof(max_msg_size);

      sock = socket(AF_INET, SOCK_STREAM, 0);
      rc = getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
                         &max_msg_size, &size_of_buf);

      printf("max=%d\n", max_msg_size);
--


 
 
 

1. Setting TCP receive buffer default size on Solaris 2.4

Hello.

I am having performance problems running a Nescape client on a Solaris 2.4
machine with ATM board (SBA-200 by Fore Systems).

I have a server with Solaris 2.3 and ATM board; if the client runs on
SunOS 4.1.3 machine, the performance is good (about 0,5 s. for 1.2 Mbyte
file). If the client runs on Solaris 2.4, the performance is much worse (a
few seconds for the same file).

Apparently the problem is the TCP receive buffer size, that is bigger for
SunOS than for Solaris. Moreover the default size is settable under SunOS,
but I could not find a way to resize it under Solaris (the default is now
8 Kbyte, slightly smaller than the MTU for ATM interfaces).
I temporarily solved the problem using a 1500-byte MTU for the ATM
interface (the time is now about 1 s.), but I am looking for a way to
increase the default TCP receive buffer size to 64 kbyte.

Any idea ?
Thanks

-- Dario

2. tty8 and /var/adm/messages (Console Log)

3. Any relationship between message size and tcp/udp socket buffer size?

4. missing pci_enable_device

5. TCP Ques - How to find actual bytes in the TCP send buffer And Connection Que length

6. Stupid Question re netscape

7. Footprint size of a TCP/IP connection ?

8. Suggestions Please

9. How to set timeout on TCP/IP based client-server connection?

10. How to set timeout on my TCP/IP connection

11. Sparc 5/Solaris 2.4 TCP/IP Problem with SL/IP connections

12. tcp/ip LAN IPs and dynamic IP ppp connections....

13. Max/min TCP buffer sizes?