|
On 02/10/99 02:24:37 AM Jocke Berggren wrote:
>I'we seen some prototype definitions around but no one have
>the select() function, I want to use select() instead of recv() in a
>socket server, cause I dont know how to handle timeout on a revc().
I haven't converted the server example fromC to RPG IV, but I have used
recv() in RPG IV. fcntl() allows you to change the socket to non-blocking
mode, which means that it won't wait for input, but immediately return from
a read() and other I/O operations. The Unix-Type API book has some good
references to copy from, which is where I found fcntl(). After the open(),
I used fcntl to set the socket to non-blocking, which works in C but not in
RPG IV. The C code is:
#include <fcntl.h>
#define F_SETFL_i = 7
#define O_NONBLOCK_i = 220
rc = fcntl(sd, F_SETFL, O_NONBLOCK);
The RPG IV code is:
D rc S 10I 0 Inz
D F_SETFL S 10I 0 Inz(7)
D O_NONBLOCK S 10I 0 Inz(00200)
D fcntl_NB PR Extproc('fcntl') Like(rc)
D 10I 0 Value
D 10I 0 Value
D 10I 0 Const
C Eval rc=fcntl_NB(sd: F_SETFL: O_NONBLOCK)
When I run the RPG code, I get an "invalid argument" error. I'm going to
tinker a bit with select() in a few days. I need to get the client side
going first!
Buck Calabro
CommSoft, Albany, NY
mailto:mcalabro@commsoft.net
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List! To submit a new *
* message, send your mail to "RPG400-L@midrange.com". To unsubscribe *
* from this list send email to MAJORDOMO@midrange.com and specify *
* 'unsubscribe RPG400-L' in the body of your message. Questions should *
* be directed to the list owner / operator: david@midrange.com *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.