POST HEAD GET 2 way communication
FredBlais
Posts: 370
Hi there,
does someone here have an object that have all the included functions to do http?
I know that get and post request and sending the requested data is done (we have working http servers)
but what I would want is the spinneret to issue http post and get to a web server and receive data.
i.e. Sending sensor data to a web server so it can store it in a database.
also, does opening a socket with tcp support dns or static ip address?
~Fred
does someone here have an object that have all the included functions to do http?
I know that get and post request and sending the requested data is done (we have working http servers)
but what I would want is the spinneret to issue http post and get to a web server and receive data.
i.e. Sending sensor data to a web server so it can store it in a database.
also, does opening a socket with tcp support dns or static ip address?
~Fred
Comments
tcpMask := SetTcpSocketMaskById(id, 0)
The rest is easy, just build the request header, send the request, and wait for the response. I'm doing a GET. To do a POST, add your name value pairs or data stream to the body of the request two lines (10,13,10,13) after the header. If you plan to call the same server several time, put the header string is a DAT section.
See the W5100 manual for client mode operation.
Spinneret sockets communicate using TCP or UDP. FTP and DNS are protocols that ride on TCP and UDP.
I made a mistake for my question about dns... I meant tcp, not ftp.
So if I understood, we have to specify the host in the get header like this : StringSend(id, string("Host: agaverobotics.com", 13, 10))
So I do not need to know the ip address of the host, I just have to know the url?
Hey, its my 100th post! first star!
No No... you need the remote host IP. The remote IP is part of the socket initialization. Socket.Connected(id) causes the Spinneret to request a socket connection on the remote host. On success, the Spinneret and remote host establish an end-to-end TCP socket connection. The next thing to do is send an HTTP message to the remote host. The "Host:" header line tells the remote host which application to fire up. Line 1 contains the requested resource and is parsed, processing happens, and a response is sent back to the Spinneret.
See the W5100 documentation for flows and check out the HTTP protocol.
Please post your PHP script.
please keep me updated with that, my needs are similars