<<I am trying to implement NOWAITed I/O using NetIPC. I seem to have
the choice of an immediate timeout and infinite time out. Anyone ever do
this?? An example is worth a thousand words. Oh and I have to do this in
COBOL as it is a COBOL shop.>>
"Timeout" is N/A for NOWAIT I/O; the operation always returns immediately,
and you use IODONTWAIT to see if the physical I/O has completed.
I don't do COBOL, but translating the following should provide what you need.
int RecvBlockNoWait(SOCKET Sock, char *buf, int maxlen, int
recvflags)
{
int dlen = maxlen;
short rlen = 0;
int flags = recvflags;
int res32 = 0;
IPCCONTROL(Sock, 1,,,,,, &res32); /* enable NOWAIT */
if (res32)
{
printf("IPCCONTROL(1) error: %d\n", res32);
fflush(stdout);
errno_IPC = res32;
return SOCKET_ERROR;
}
IPCRECV(Sock, buf, &dlen, &flags,, &res32);
if (res32)
{
printf("Waited IPCRECV error: %d\n", res32);
fflush(stdout);
errno_IPC = res32;
return SOCKET_ERROR;
}
dlen = 0;
if (IODONTWAIT(Sock, buf, &rlen)) /* try to complete
the receive */
{
dlen = rlen;
}
IPCCONTROL(Sock, 258,,,,,, &res32);
if (res32)
{
printf("IPCCONTROL(258) error: %d\n", res32);
fflush(stdout);
}
IPCCONTROL(Sock, 2,,,,,, &res32); /* disable NOWAIT */
if (res32)
{
printf("IPCCONTROL(2) error: %d\n", res32);
fflush(stdout);
}
return dlen;
}
Steve
Steve Dirickson WestWin Consulting
(360) 598-6111 [log in to unmask]
|