NetDuino as pachube's like webserver
#1
Posted 11 October 2011 - 06:41 PM
Arduino, MODs e DIY: blackstufflabs.com
#2
Posted 12 October 2011 - 01:14 PM
#3
Posted 12 October 2011 - 01:30 PM
#4
Posted 12 October 2011 - 03:20 PM
I am not sure how much data you want to send per request but assuming is it only a small amount, say less than an ethernet packet of around 1500 bytes, then I would use "http get" and add the data to the query string.
such as "http://localaddress?...MyDataGoesHere"
the data itself would have to be url encoded. You would have to find or make a function to do this.
The response wouldn't have to say much just make sure it includes a http response code for success ie. 200.
you can pull the data off the query string by calling the request.Uri property and using everything after the = sign.
Then you would have to unencode the data.
I am sorry I cant give you working code, but it would look something like this:
int count = connectionSocket.Receive(bytes);
Request request = new Request(bytes);
string[] arraySplit = request.Uri.Split('=');
string data = UrlUnEncode( arraySplit[1]); //keep everything after the = sign
Hope this helps
Thanks for your reply...
Its a good idea to make a query string but.... i need to make a good and safe autentication.
I dont want to made a single query string with the username and password (maybe) like: http//localaddress?id=MyID&pass=MyPass&data=MyData...etc etc
Its unsafe...
I want to made something like that:
Client: Hi
Server: Pass?
Client: MyPass
Server: Username?
Client: MyUsername
Server: ok... good... how many data?
Client: 1
Server: Ok, tell me!
Client: 30
Server: closing
Client: Bye
With arduino i have used a sketch called "PachubeClient" that works exactly as above.
But... i dont have understand HOW (with which class) I can made the server's reply to an http request (not a query string).
On msdn i have read something about HttpWebRequest and HttpWebResponse for comunications between a client and server...
thanks
a.
Arduino, MODs e DIY: blackstufflabs.com
#5
Posted 12 October 2011 - 03:33 PM
-- H.L. Mencken, "What I Believe"
#6
Posted 12 October 2011 - 04:00 PM
The methods you are outlining don't differ in safety. Why do you think the second is safer than the first?
I have read something on internet about that.
Do you think that a query string is safer as an http requests authentication?
Its more easy for me to parse a query string because i have some example in my book: http://goo.gl/XhYuG
Arduino, MODs e DIY: blackstufflabs.com
#7
Posted 12 October 2011 - 04:23 PM
-- H.L. Mencken, "What I Believe"
#8
Posted 12 October 2011 - 04:41 PM
"I have read something on the internet" is a bad base for security considerations.
You're right, thanks for your reply... I will use the query string on my project.
Thanks again
A.
Arduino, MODs e DIY: blackstufflabs.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users