Re: Sending HTTP request
- From: Hammie <JaapvanHamersveld@xxxxxxxxx>
- Date: Tue, 24 Mar 2009 04:57:34 -0700 (PDT)
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:
HelloIt's matter of opening a socket to the address ofwww.xxxxx.comhost
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
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
.
- Follow-Ups:
- Re: Sending HTTP request
- From: google
- Re: Sending HTTP request
- References:
- Sending HTTP request
- From: Hammie
- Re: Sending HTTP request
- From: Dr.UgoGagliardelli
- Re: Sending HTTP request
- From: Hammie
- Re: Sending HTTP request
- From: Dr.UgoGagliardelli
- Sending HTTP request
- Prev by Date: Re: Sending HTTP request
- Next by Date: Re: Offsite storage of save files
- Previous by thread: Re: Sending HTTP request
- Next by thread: Re: Sending HTTP request
- Index(es):
Relevant Pages
|