Tcpip read problem QNX4.25/Tcpip 5.00A

Hello,
I have two QNX machines communicating using Tcpip (for test purposes). The
client sends a 26 byte command message. The server is in an infinite loop
with a blocking read statment at the top:

// The server
char msg[1024];
*
sock = socket(AF_INET, SOCK_STREAM, 0);
*
server.sin_family = AF_INET;
server.addr.s_addr = INADDR_ANY;
server.sin_port = htons(port);
bind( sock, (struct sockaddr *)server, sizeof(server) );
*
listen( sock, 5 );
*
mysock = accept( sock, 0, 0 );
*
if((bytes = read(mysock, msg, size(msg)))) <= 0 ) // Read loop
break;
*
*
if( byte == 0 )
close(mysock);


THE PROBLEM: Immediately after startup, the very first message received by
the ‘read’ statment in the server always returns 0 bytes and no data is
placed in the msg buffer. The ‘read’ becomes unblocked as expected, but no
data is read-in. However, subsequent messages are read just fine! It is only
the first message after startup that seems to get lost.

What am I doing wrong or what could I be missing?

Using QNX 4.25, Tcpip 5.00A

RN wrote:

Hello,
I have two QNX machines communicating using Tcpip (for test
purposes). The client sends a 26 byte command message. The server is
in an infinite loop with a blocking read statment at the top:

// The server
char msg[1024];
*
sock = socket(AF_INET, SOCK_STREAM, 0);
*
server.sin_family = AF_INET;
server.addr.s_addr = INADDR_ANY;
server.sin_port = htons(port);
bind( sock, (struct sockaddr *)server, sizeof(server) );
*
listen( sock, 5 );
*
mysock = accept( sock, 0, 0 );
*
if((bytes = read(mysock, msg, size(msg)))) <= 0 ) // Read loop
break;
*
*
if( byte == 0 )
close(mysock);


THE PROBLEM: Immediately after startup, the very first message
received by the ‘read’ statment in the server always returns 0 bytes
and no data is placed in the msg buffer. The ‘read’ becomes
unblocked as expected, but no data is read-in. However, subsequent
messages are read just fine! It is only the first message after
startup that seems to get lost.

What am I doing wrong or what could I be missing?

Using QNX 4.25, Tcpip 5.00A

I guess, you didn’t use select() … there’s a complete example in
the docs of ‘TCP/IP for QNX4.25’ (Programmers Guide → A Scoket-based
IPC Tutorial → Stream connection → Establishing a socket →
tut7.c).

HTH,

:Karsten.


Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373