Operating System - HP-UX
1821802 Members
3423 Online
109637 Solutions
New Discussion юеВ

Explanation for setsockopt()

 
Amith_2
Frequent Advisor

Explanation for setsockopt()

Hello.
I am experiencing a delay when i sent message with size of 2200 bytes from my server program on HP-11 to the client program which is running on windows dos box.
Everytime when a message of size 2200 bytes is sent there is a delay in receiving the next request from the client. I was using the following options for the socket ,
setsockopt(circuit,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one));
when i changed it to
setsockopt(circuit,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one));
the program started working fine.
Could anyone please explain to me what is the difference in the above two setsockop() defenitions and what caused the dealy in the previous case.

4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: Explanation for setsockopt()

Shalom Amith,

http://www.informatik.uni-frankfurt.de/doc/man/hpux/getsockopt.2.html

http://devrsrc1.external.hp.com/STK/cgi-bin/display-manpage.cgi?manpage=setsockopt&section=2&manOSName=hpux&manOSVersion=11.00

http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html?manpage=/usr/share/man/man2.Z/getsockopt.2

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Antonio Cardoso_1
Trusted Contributor

Re: Explanation for setsockopt()

have a look at:
man setsockopt
man tcp

in fact, the second setsockopt() doesn't contradict first one, but just adds the TCP option that "causes small amounts of output to be sent immediately",
"If TCP_NODELAY is set, the system sends small amounts of output immediately rather than gathering them into a single packet after an acknowledgement is received."

antonio.
Amith_2
Frequent Advisor

Re: Explanation for setsockopt()

Hello Antonio,

Does it mean that i can set two options together like mentioned below for my socket??

setsockopt(circuit,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one));
setsockopt(circuit,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one));

rick jones
Honored Contributor

Re: Explanation for setsockopt()

99 times out of 10, if setting TCP_NODELAY increases the performance of an application, it suggests the application is doing something doubleplusungood like presenting "logically associated data" (aka message) to the transport in more than one send call. In such situations, the proper fix is to use writev() or sendmsg().

To fully see what is happening, please take and post a tusc system call trace and a tcpdump packet trace of your server program talking to the Windows client.
there is no rest for the wicked yet the virtuous have no pillows