Re: Sending HTTP request



On 24 mrt, 10:35, "Dr.UgoGagliardelli"
<do.not.spam.me.ple...@xxxxxxxxxx> wrote:
il 23/03/2009 13.57, Scrive Hammie 43840640:



On 23 mrt, 13:32, "Dr.UgoGagliardelli"
<do.not.spam.me.ple...@xxxxxxxxxx> wrote:
il 23/03/2009 13.15, Scrive Hammie 43882312:

Hello
How can I sent directly a request to a HTTP server from the I-serie
from CLLE or RPGLE
The message should be sent if certain MONMSGxxxx are capitured
I will send a message to a provider who than can send an SMS to a
mobile phone.
something like this:
http://www.xxxxx.com/xml/sms/?username=[username]
&password=[password]&originator=[originator]
&recipients=[recipient(s)]&message=[message]
I hope someone can help me
Regards
Jaap
It's matter of opening a socket to the address ofwww.xxxxx.comhost
using port 80, and write a request using HTTP protocol, that's defined
by HTTP RFCs (e.g rfc1945)

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

well that's sound easy, but I'am a newby in this matter
Can you explain me how to do that??

More or less the same way a browser would.
Using gethostbyname() API you'll be able to get the host address.
With socket() API you'll create a new socket descriptor.
With bind() API you'll create a communication path from your local host
to remote host using the socket descriptor.
With connect() API you'll open the communication path.
With a combination of iconv() and write() API you'll send the request to
the remote web server.
You can get the response too, with a combination of read() and iconv() API.
When finished you should close() the socket descriptor.
All the above APIs are documented in iSeries Infocenter, if you
installed OS400 "System Openness Include" option, in QSYSINC library you
have headers files for C language (both struct definition and function
prototypes), to use such APIs in RPGLE you shold translate them into
RPGLE, or find someone that already did it.
For example, the definition of gethostbyname() funtion (in qsysinc/h
netdb member) is:

struct hostent *gethostbyname(char *host_name)

In other word is a function that given a null terminated string
representing the host name, returns a pointer to an hostent structure
(defined in netdb too). So in RPGLE the prototype could be

D gethostbyname      pr      *  extproc('gethostbyname')
D   host_name                *  options(*String) value

defining hostent structure in RPGLE is not so simple, in C is defined as:
struct hostent {
   char         *h_name;
   char        **h_aliases;
   int           h_addrtype;
   int           h_length;
   char        **h_addr_list;};

while translating an int it's easy, it's not the same easy to handle in
RPGLE somewhat like char **h_addr_list that's a NULL terminated list of
pointers each one contains a possible address of the remote host. Each
address has the format of the structure in_addr defined in
qsysinc/netinet in member.
Hostent structure in RPGLE would be:
D hostent      ds             based(hostent_p) qualified
D  h_name                   *
D  h_aliases                *
D  h_addrtype             10i 0
D  h_length               10i 0
D  h_addr_list              *
The function call become:

C            eval   hostent_p = gethostbyname('www.xxxxx.com')

After the call h_addr_list points to an array of an undefined number of
elements (the las one equals to *NULL) and each element is made by
h_length bytes.
Struct in_addr is defined as:
struct in_addr {
    unsigned long   s_addr;};

That is:
D in_addr    ds               based(in_addr_p) qualified
D  s_addr                10u 0

so getting the very 1st address in the list is matter of:

C           eval    in_addr_p = hostent.h_addr_list
C* do something with in_addr.s_addr that's the 1st address

getting the second, using pointer arithmetics:

C           eval    in_addr_p = (hostent.h_addr_list+hostent.h_length)

Even if in most cases youl'll use the 1st addresss, you can loop until
you'll find a *NULL to use all addressess returned (sometimes a DNS can
define an host name with multiple addresses), e.g

D paccum                 10i 0  inz(0)

C           eval    in_addr_p = hostent.h_addr_list
C           dow     in_addr_p <> *NULL
C* do something with in_addr.s_addr
C           eval    paccum = paccum + hostent.h_length
C           eval    in_addr_p = (hostent.h_addr_list+paccum)
C           enddo

You can do the same with h_aliases, but its not so intresting for your
objective.

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Thanks for that answer
regards
Jaap
.



Relevant Pages

  • Re: Sending HTTP request
    ... Using gethostbynameAPI you'll be able to get the host address. ... With bindAPI you'll create a communication path from your local host to remote host using the socket descriptor. ... All the above APIs are documented in iSeries Infocenter, if you installed OS400 "System Openness Include" option, in QSYSINC library you have headers files for C language (both struct definition and function prototypes), to use such APIs in RPGLE you shold translate them into RPGLE, or find someone that already did it. ...
    (comp.sys.ibm.as400.misc)
  • Re: Sending HTTP request
    ... Using gethostbyname() API you'll be able to get the host address. ... With socketAPI you'll create a new socket descriptor. ... have headers files for C language (both struct definition and function ...
    (comp.sys.ibm.as400.misc)
  • Re: Pointer to "base" type - what does the Standard say about this?
    ... Since the `api' is the first element ... in each struct, it is always safe to convert the struct pointer to ... all of my implementations can (and in fact ... The interfaces are used by the rest of the ...
    (comp.lang.c)
  • Re: Decrypting EFS file
    ... However, this API has a callback that must be fed with data from the file, ... INCLUDING the $EFS stream containing the encryption-related stuff. ... > DWORD m_dwVersionMinor; ... > struct EFS_ENTRY_HEADER ...
    (microsoft.public.windows.file_system)
  • Re: PInvoke TCHAR[] ??? Having trouble with this.
    ... |> Please show us your C# struct declaration, ... | public System.UInt32 DriverType; ... | internal struct SP_DEVINFO_DATA ... Try calling the API passing a IntPtr as third argument (change the API ...
    (microsoft.public.dotnet.languages.csharp)