Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1045163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:56:34+00:00 2026-05-16T15:56:34+00:00

From this rpg socket tutorial we created a socket client in rpg that calls

  • 0

From this rpg socket tutorial we created a socket client in rpg that calls a java server socket

The problem is that connect()/send() operations blocks and we have a requirement that if the connect/send couldn’t be done in a matter of a second per say, we have to just log it and finish.

If I set the socket to non-blocking mode (I think with fnctl), we are not fully understanding how to proceed, and can’t find any useful documentation with examples for it.

I think if I do connect to a non-blocking socket I have to do select(…, timeout) which tells us if the connect succeed and/ we are able to send(bytes). But, if we send(bytes) afterwards, as it is now a non-blocking socket (which will immediately return after the call), how do I know that send() did the actual sending of the bytes to the server before closing the socket ?

I can fall back to have the client socket in AS400 as a Java or C procedure, but I really want to just keep it in a simple RPG program.

Would somebody help me understand how to do that please ?
Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:56:34+00:00Added an answer on May 16, 2026 at 3:56 pm

    In my opinion, that RPG tutorial you mention has a slight defect. What I believe is causing your confusion is the following section’s code:

    …
    Consequently, we typically call the
    send() API like this:

    D miscdata        S             25A
    D rc              S             10I 0
    
    C                   eval      miscdata = 'The data to send goes here'
    C                   eval      rc = send(s: %addr(miscdata): 25: 0)
    c                   if        rc < 25
    C*  for some reason we weren't able to send all 25 bytes!
    C                   endif
    

    …

    If you read the documentation of send() you will see that the return value does not indicate an error if it is greater than -1 yet in the code above it seems as if an error has occurred. In fact, the sum of the return values must equal the size of the buffer assuming that you keep moving the pointer into the buffer to reflect what has been sent. Look here in Beej’s Guide to Network Programming. You might also like to look at Richard Stevens’ book UNIX Network Programming, Volume 1 for really detailed explanations.

    As to the problem of determining if the last send before close() did the actual send … well the paragraph above explains how to determine what portion of the data was sent. However, calling close() will attempt to send all unsent data unless SO_LINGER is set.

    fnctl() is used to control blocking while setsockopt() is used to set SO_LINGER.

    The abstraction of network communications being used is BSD sockets. There are some slight differences in implementations across OS’s but it is generally quite homogeneous. This means that one can generally use documentation written for other OS’s for the broad overview. Most of the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From this post : I would first suggest that you optimize your dependentObservable (a.k.a.
We've been given a stored procedure from our RPG folks that returns six data
From this tutorial http://www.brighthub.com/internet/web-development/articles/11010.aspx I found the code below. Is there a way to
From this array how could I get that array which first element is 128
I asked about consuming a WCF service from RPG here and received this response:
From this context: import itertools lines = itertools.cycle(open('filename')) I'm wondering how I can implement
From this link the author suggested: table.setWidth(100%, true); table.setColumnWidth(nameColumn, 35.0, Unit.PCT); table.setColumnWidth(addressColumn, 65.0, Unit.PCT);
From this question & the answers - What is the correct answer for cout
From this code I can call bmwCars.CopyToDataTable() as I expected. var bmwCars = from
From this question I learned Double.NaN is not equal to itself. I was verifying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.