Operating System - HP-UX
1832281 Members
2126 Online
110041 Solutions
New Discussion

Re: Problem about reading data on a TCP socket

 
Guilhaumou Vincent2
Occasional Contributor

Problem about reading data on a TCP socket

Hi,

I support an application compiled under HP10.20 and running on B2000 station under HP11.11, which is an HMI displaying data received from other equipments. This application is composed with several processes which one is dedicated to the communication between HMI processes and the application running under other equipments. The communication in this process is based on sockets and pipes : pipe with the HMI processes, socket UDP to manage the detection of clients, sockets TCP to receive and to send data from/to clients of other equipments when the connexion is established with them.
I think that the managment of the communications is classic :
- loop calling the select function to wait data from all the file descriptors of the sockets and pipes added through the FD_SET macro
- check the return of the select function
- if the return of select function > 0, detection of the file descriptor concerned through the FD_ISSET macro
- call recv function on the file descriptor concerned
Problem is that sometimes, when there is much traffic, the return of the select function is >0, the file descriptor detected is a TCP socket, but the recv function on this TCP socket returns 0. Our application treats that as a disconnexion !
How may you explain that the select function detects data on a socket (return>0) and that the recv function on this socket is unable to read the data (return=0)?

 

 

P.S. This thread has been moved from Workstations - Itanium-Based, hp9000, Visualize to HP-UX > networking. -HP Forum Moderator

4 REPLIES 4
rick jones
Honored Contributor

Re: Problem about reading data on a TCP socket

With the exception of one (IIRC obsucre) flavor of non-blocking I/O, a read/recv return of 0 does indeed mean disconnection, and that is a condition under which select() should return with the socket writable - what makes you think you are getting a mistaken read return of zero?

there is no rest for the wicked yet the virtuous have no pillows
Dennis Handly
Acclaimed Contributor

Re: Problem about reading data on a TCP socket

The correct forum for HP-UX networking questions is the EBC forum: HP-UX > networking:

http://h30499.www3.hp.com/t5/Networking/bd-p/itrc-245

Guilhaumou Vincent2
Occasional Contributor

Re: Problem about reading data on a TCP socket

OK, I have transferred the problem to the forum "HP-UX > networking", with adding a code extract.
Thanks.
Dennis Handly
Acclaimed Contributor

Re: Problem about reading data on a TCP socket