Ask the Expert

Trouble with a socket server program in ILE

I have written a socket server program in ILE and am experiencing some trouble with the shutdown of the socket if no data is available from the client. There are two APIs that I have tried using. One is the Fcntl() API, which will not compile because the program tells me the parameters are not defined. I have them defined in the D specifications. The other API is the Select(), which according to the IBM RedBook (Who Knew You Could ...)will look for a client that is ready to connect or send data. The client system I am working with always keeps an open connection even if no data is available to send. What is the best way for me to get the server socket to not get locked on the Recv() API when no data is available from the client system?


First things first. Your undefined specifications are probably header and parm definitions that are usually written in "C" and located in one of the files in QSYSINC. There should be a list of all of the headers required in the definition of the API. You would need to look up each undefined parameter and create the "D" specs for the definition, unless you can find it in RPGLE format in the QSYSINC library (Some are there, some aren't). The second problem could be the way you are binding to the remote or local object, and/or the socket options. I would use the API setsockopt, which will allow you to set optional values for timeouts and failed bindings. With this API, you can specify the layer to apply the values. This will allow you to perform your open, listen and recv and allow the socket or layer to expire when no data or an error occurs. This API is detailed at IBM's setsockopt()--Set Socket Options page.


This was first published in April 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: