using recv () in tcpip

I want to see if there is any message to read before
caling recv() function, what’s the best way of doing it?
should I use select()?if anyone got any suggestion
or example…please let me know thanx.

George

George,

You can use the signal/ioctl combination to ensure that when you issue your
recv(), there is something there to read. It’s essentially an ISR that is
triggered by the arrival of data on your Socket.

if( bind( DataSocket, (struct sockaddr *) &dataSocketName,
sizeof(dataSocketName) ) < 0 )
{
logError(“main: Could not bind receive socket.”);
}

// Identify the routine that will read data from the socket when needed
signal( SIGIO, SocketIOHandler );

// Ensure that our process is to receive the SIGIO signal, which is raised
when
// there is data to read from the socket.
process_id = getpid();
if( ioctl( (int) DataSocket, (long) SIOCSPGRP, (pid_t *) &process_id ) <
0 )
{
logError( “main: ioctl SIOCSPGRP failed.” );
}

James Carmody
Atomic Energy of Canada Ltd.
carmodyj@aecl.ca

“george” <gccst@westinghouse.com> wrote in message
news:a2aa64$5o7$1@inn.qnx.com

I want to see if there is any message to read before
caling recv() function, what’s the best way of doing it?
should I use select()?if anyone got any suggestion
or example…please let me know thanx.

George