Re: What shutdown(socket, SHUT_RD) does?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi



> Could somebody explain the difference between
> "shutdown(socket, SHUT_RD)"   and
> "shutdown(socket, SHUT_WR)"

1 is for write
1 is for read

> Condition:
> 1. TCP connection has been established
> 2. Side A call shutdown(socket, SHUT_RD)
>
> Question:
> 1. Could the side B send(...), and what is the result if call send(...)?
> 2. How could side B know that side A has called "shutdown(socket,
SHUT_RD)"?

1. no send is still valid, call / send() is no different still calls the
function
   i do hope you are checking the return value from this
2. if you try to read it will return 0 to say its closed
   if it has not been done it will hang until either data is send or it has
been closed
   if you use non-blocking it will return 0 if closed and EAGIAN if there is
no data

i think this is correct sombody correct me if i am wrong

> I have a sample below,
> 1. why the program doesn't exit with the singal SIGPIPE?
> 2. why side A could do send while side B has call "shutdown(socket,
> SHUT_RD)"?

i am gueesing the send never gets called when the other side is closed



-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux