Data Transfer using TCP/IP for QNX4.25

Hi,

We are working on a project requring data transfer using TCP/IP
protocol. We have developed a microcontroller based device for monitoring of
various parameters (digital input conditions) in the field. The equipment
has a 10 base T ethernet port is is capable of data transfer using TCP/IP
protocol. The device is programmed as a TCP/IP server. This devices is not
runnig a QNX RTOS. It is capable of detecting a TCP/IP connection, receiving
a 4-byte query packet from a client requesting data and respond with the
data packet.

We have utilised a computer system installed with QNX 4.25, TCP/IP for
QNX 4.25 and Watcom ‘C’ 10.6 for development of a TCP/IP client program.
This client application establishes a TCP/IP connection with our device,
sends a 4-byte packet and receives data response from device. The received
data is stored in shared memory. We have used TCP/IP stream communication
functions (send, recv, socket, connect, close). At startup, this aplication
establishes a connection and only if connected query packet is sent every
10 seconds. If error is returned by send or recv, before next query a call
to close is made and a new connection is setup. If the connection is not
successful, query is not sent.

We could get both the modules (QNX-based client and microcontroller
based server) running without any problem. At the time of testing those for
exception conditions, we have encountered a problem at client end.We require
help in solving the same.

This is the first time we have attamepted data transfer using TCP/IP for
QNX. Earlier we have developed data transfer programs using serial
communiactions (RS 485, RS232, RS 422). Normally when the cable is faulty,
program sending query will wait for response, timeout if no response
received and again send a new query packet.

We have utilised similar flow in programming TCP/IP client module. The
recv function does not block forever. We have set socket options for the
program to unblock if no data response is received. Normally when the
ethernet link is connected, query-response are working fine. During the run
of the program , if we disconnect the ethernet cable, QNX client detects no
response received and ends the connection. It then periodically tries to
establish connection. When the ethernet cable is reconnected, QNX client
program establishes a connection successfully, exits with a message “Broken
pipe”. We wish to capture this error and handle the same in our program.
Please tell us how this can be done.

Thanks,
Krupa

Krupa <seto@vsnl.com> wrote:

Hi,

We have utilised similar flow in programming TCP/IP client module. The
recv function does not block forever. We have set socket options for the
program to unblock if no data response is received. Normally when the
ethernet link is connected, query-response are working fine. During the run
of the program , if we disconnect the ethernet cable, QNX client detects no
response received and ends the connection. It then periodically tries to
establish connection. When the ethernet cable is reconnected, QNX client
program establishes a connection successfully, exits with a message “Broken
pipe”. We wish to capture this error and handle the same in our program.
Please tell us how this can be done.

Catch the SIGPIPE signal. Or, even, ignore it.

signal(SIGPIPE, SIG_IGN)

If you do this, your function will return -1, errno will be set to EPIPE.

Pretty standard Unix pipe/strea processing.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.