|
> I am working on a sockets client application that needs to > connect to a > remote host. The program is called passing the TPC/IP > address in dotted > form as well as the port to connect to. Fun fun fun. > I am having trouble translating the dotted TCP/IP address to > a four byte > binary address. The function in am trying to use is : > (from the AS400 V3R7 online library manual for sockets programming) > Document Number SC41-4422-01 Your question prompted me to look into my own sockets code and found that I didn't support IP addresses... now I do. Here's what I did... First, I try to resolve the system name using gethostbyname() (which I originally thought would resolve an IP address as well as a host name). If that returns *NULL, I then invoke "EVAL sin_addr=inet_addr(%addr(ServerName))" (where ServerName is the null terminated IP address). > My RPG is as follows: > > D InetAddr PR 10u 0 ExtProc('inet_addr') > D SocketId 15A Value inet_addr wants a pointer to a character string (null terminated) that contains the IP address. Your prototype should look like... D inet_addr PR 10U 0 Extproc('inet_addr') D * Value > C EVAL sin_addr = inetaddr(TcpAddr) You need to pass the address of TcpAddr to the inet_addr function... so your code should look something like... C EVAL sin_addr = inetaddr(%addr(TcpAddr)) david * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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-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.