× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



If you read the article published by Carsten you will see the steps you need.



--
Jim Oberholtzer
Chief Technical Architect
Agile Technology Architects


------ Original Message ------
From "datil400" <datil400@xxxxxxxxx>
To "Midrange Systems Technical Discussion" <midrange-l@xxxxxxxxxxxxxxxxxx>
Date 10/12/2024 12:15:04 PM
Subject Re: User-Defined TCP/IP Server

Hi Patrik,

thanks for your help. I don't think I made myself clear in my initial post.

The User-tcp server is an existing, tested and working server program. My
idea is to integrate it into the system as if it were one of the other
ones. Using commands ADDTCPSVR, making the job appear as a server job with
Change Job (QWTCHGJB) API and start and end the service with commands
STRTCPSVR and ENDTCPSVR. But I am not sure how to use these tools. I can't
find enough information to do so.

Javier Mora

El sáb, 12 oct 2024 a las 10:57, Patrik Schindler (<poc@xxxxxxxxxx>)
escribió:

Hello Javier,

Am 11.10.2024 um 19:45 schrieb datil400 <datil400@xxxxxxxxx>:

> I am interested in conveniently configuring a user-defined tcp server.

Programming is not configuring. :-)

Development of custom TCP server is *almost* the same as doing the same on
Linux. Keyword is "socket programming". Searching for that should let you
participate in the huge amount of examples and explanations how to do this
on Linux.

Personally, I prefer to use C for that purpose, because one will find
truckloads of examples in the net for that language. You can do it in RPG,
though. Search for Scott Klement's socket tutorial.

For some IBM i centric introduction to C, I recommend having a look at
Chris Hird's "Let's C" series of blog entries:
https://www.shieldadvanced.com/Blog/lets-c/

I have done a simple UDP (not TCP) server project myself, because this
spares me to tackle with fork() vs. spawn() and lessens overhead for TCP
session establishment.

https://github.com/PoC-dev/asterisk-translate-clid

Things to keep in mind:
- IBM i is a native EBCDIC platform. The existing services from IBM
transparently do translation from EBCDIC to ASCII and back for e. g. http,
ftp, ssh, you name it. You'll need to do this yourself when programming
your own server.
- Many TCP examples for Linux heavily rely on the fork() call to free the
initial connection and thus enable parallel processing. IBM i doesn't have
fork, but spawn() which is different but serves a similar purpose. See
"UNIX C Applications Porting to AS/400" (SG24-4438) and "UNIX C
Applications Porting to AS/400 Companion Guide" (SG24-4938) for details.
Note: I have not yet understood in detail how to use spawn() as a fork()
replacement.
- Using PFs/LFs (Record I/O) is somewhat cumbersome in C.
- You may want to use your own subsystem (description) and start it in
qstrup to autostart your application as a background (batch) job.
- You may want to add a signal handler to have your application terminate
cleanly when the SBS is ended.
- You can choose to leave aside all network programming and SBS hassle,
and use inetd instead — which is conviently available in IBM i also. Your
program just uses stdin/stdout to communicate with the network peer, while
inetd takes care about spawn() and network stuff.
https://en.wikipedia.org/wiki/Inetd — Note: This still must do the EBCDIC
<=> ASCII translation yourself. Also, inetd launches your application on
every single incoming request. This adds a notable CPU overhead and delay
when used on very low end machines.

Does that help?

:wq! PoC



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.