Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) |
Notice: | Welcome to the Digital UNIX Conference |
Moderator: | SMURF::DENHAM |
Created: | Thu Mar 16 1995 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 10068 |
Total number of notes: | 35879 |
A software partner who is porting to Digital UNIX has asked how to determine if a remote socket connection has been broken. He is doing reads to a socket and needs to know in the case where there is no data, whether the socket connection has been broken. What is the recommended way to do this? I suggested that he try setting the SO_KEEPALIVE parameter for setsockopt, but this does not meet his need (see attached notes). Thanks, Karen Dorhamer Software Partner Engineering From: US3RMC::"[email protected]" "Hu Rui" To: "[email protected]" <hydra::axpdeveloper> CC: Subj: Socket Read Return Value We are Digital's developing partner. I have some question about socket. I use Digital Unix Version 3.1 and 4.0. Two machine. I use socket for both IPC in the same machine also in differernt machine. If I read from a non_blocking TCP socket. How can I know the remote side has closed connection? From read's return value or signal. I need very detailed knowledge, this is very important for our programming. I need to know. While read from non_blocking socket: - In case read got something - In case read got nothing but connection is still on - In case read get nothing also the connection is broken The read's return value, errno, signal. How can I seperate the later 2 situation? While read from blocking socket: - In case read got something - In case read got nothing but connection is still on - In case read get nothing also the connection is broken The read's return value, errno, signal. How can I seperate the later 2 situation? Regards. _________________________________________________ I have the TCP protocol transition diagram in my hand. I need to know how I can know the state of my socket. I need function like. - Input is the socket file id - Output is the current state of that socket. I think Digital must implement TCP protocal according to the same state transition diagram I have (from Richard Stevens' TCP/IP Illustrated Volume 1). I need function that asscess low level information about socket. Tell me currently my socket is in what state? How does Digital implement the TCP protocol? The man page does not have very specific explanation about socket read and write. _________________________________________________ I know SO_KEEPALIVE. It is not very helpful. Normally the default time is 2 hours. If a connection keep idle for 2 hours than if assume to be dead. In fact. I think the OS must have a internal table that keep all the information about the socket. If the remote side is closed normally, this table must change. So the read can return a different value. From my own test I prove it is true. But I need confirmation. This is not documented any where. How is portability? We have had lots of problem with sockets. So it is very important for us to have a good knowledge of socket, to handle all the possible situation. We have not found any good detailed material that can answer my question. How the TCP is implemented in Digital Unix? How is Digial TCP implementation compare with for example AIX, SCO, HP, NT..... Regards. _________________________________________________
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
8578.1 | VAXCPU::michaud | Jeff Michaud - ObjectBroker | Fri Jan 24 1997 11:25 | 26 | |
> If I read from a non_blocking TCP socket. How can I know the remote side > has closed connection? you'll get back a return value of 0 from read(2) if TCP has determined the connection has been explicitly closed by the remote side. You will never get back 0 from read(2) on a TCP socket for any other reason. If it's non-blocking and the connection is still open, but there is simply no data, you'll get back a return value of -1, and errno will of been set to EWOULDBLOCK. If there was data then read(2) will return the number of octets copied to your buffer. If the socket is blocking, you will block as long as the connection is still open and there is no data to read. Otherwise it's the same as for non-blocking (0 will be returned when connection is closed *and* you've already read all data received on the socket prior to the close). You could also get back -1 and errno EINTR if you are playing with signals in the process. > From read's return value or signal. If you have turned on async notification for the socket, you should also get a SIGIO when the connection is closed. And if you are select(2)'ing on the socket, the socket will be both readable and writtable. | |||||
8578.2 | Thanks | HYDRA::DORHAMER | Fri Jan 24 1997 12:00 | 3 | |
Thanks! I'll pass the info on to the software partner. Karen | |||||
8578.3 | hope it helps.. | AUBER::DORNANO | Mon Jan 27 1997 04:40 | 14 | |
>We have not found any good detailed material that can answer my question. >How the TCP is implemented in Digital Unix? Digital follows the RFCs. See SPD, man netintro(7), inet(7), ip(7), tcp(7), udp(7), etc.. and also Network and Communications Overview. >Tell me currently my socket is in what state? You could do a "netstat -a[n]", from the shell, or even from a prog... Pascal |