ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Number of jobs running in a Port for Socket programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Number of jobs running in a Port for Socket programming

    Hello Folks,

    I am working on few socket programs and I would like to know, if there is a way to determine how many jobs are actively running in a particular Port at any given point of time.

    There is a command NETSTAT on OS/400 which can give few details regarding this.
    Run the command NETSTAT, take option 3 - which will list down the TCP/IP Connection Status / Ports that are active in the System. Taking F11 will display the number of bytes of data being transferred and F10 key will display the Active opens and Passive opens.

    But, I would like to be able to retrieve the number of jobs details from a CL program using some system commands or if there is an API to help me do this on RPG.

    Once I accomplish this, I would like to programmatically control the job submission in Sockets.

    I mean - if the number of active jobs in a Port has reached a certain number / limit - I would like to know if there is a way to divert the job to a different port with less number of jobs running in it.

    Your answers would be of great help.

    Thanks,
    Yagneswar.

  • #2
    Re: Number of jobs running in a Port for Socket programming

    It's possible to get a list of the open TCP sockets, similar to NETSTAT, with the QtocLstNetCnn API.

    Are you writing your own TCP/IP server program? If so, it's your code that controls the way jobs are submitted... this is done individually by each TCP/IP server program, so unless you're writing the server yourself, you cannot control how jobs are submitted... but, if you are writing it, you should already know how to do this!

    There's no way to "divert" to a different port, unless that's something built-in to your application protocol? (For example, HTTP can do it.. you send a 30x response indicating a different URL to connect to, and that URL could have a port number in it...) Remember, it's the client that determines which port to connect to, so the client would need to establish a connection on the original port, then get a message back from the server indicating a different port, then it could disconnect and re-connect to the new one.

    But... why would you ever want to do this? There's no limit to the number of connections that can be handled on a single port, and it has no impact on performance (unless, of course, it has to do with the way a particular program was written) so why would you want to do this?? It makes things more complicated without providing any benefits. Unless, I'm just not thinking of what they'd be....

    Comment

    Working...
    X