404 posts
Location
St. Petersburg
Posted 15 January 2013 - 01:04 PM
syntax:
local url, data = http.listen(60) -- timeout = 60 seconds
url, data = http.listen() -- no timeout
description:
similar to rednet.receive, but is receiving via http instead of rednet
listens for timeout seconds if given, or until terminated if not given
returns a string of the URL and a file buffer of data received
7508 posts
Location
Australia
Posted 15 January 2013 - 01:10 PM
So do you mean this as it listens for 60 seconds and then pulls the website data after the 60 seconds? or do you want it to do something like this? Or am I misunderstanding completely?
http.request( url )
local timeout = os.startTimer( 60 )
while true do
local event = { os.pullEvent() }
if event[1] == "http_success" then
print( "Got response" )
return
elseif event[1] == "http_failure" then
print( "No response from server" )
error()
elseif event[1] == "timer" and event[2] == timeout then
print( "A timeout has occurred with no response from the server." )
error()
end
end
404 posts
Location
St. Petersburg
Posted 15 January 2013 - 01:24 PM
basically, it listens for any server on the internet to post data to it, then returns the url and postdata
timeout is when it fails and returns the the rest of the code
404 posts
Location
St. Petersburg
Posted 15 January 2013 - 01:29 PM
i am trying to implement ComputerCraft-side servers to pass information back and forth between the internet and rednet.
i got this idea from working with javascript:
var http = require("http"), server;
server = http.createServer(function(request, response) {
… server code …
});
server.listen(8080)
note: the 8080 in this case is the port the server "listens" to, not the timeout
3790 posts
Location
Lincoln, Nebraska
Posted 15 January 2013 - 01:30 PM
You can easily write a funciton that does this for you.
1054 posts
Posted 15 January 2013 - 01:41 PM
Actually, TheOriginalBit posted one in this thread. :P/>
404 posts
Location
St. Petersburg
Posted 15 January 2013 - 01:50 PM
You can easily write a funciton that does this for you.
there is no way to receive without specifying a URL with the given functions
http.listen does not specify which URL it is listening to
Actually, TheOriginalBit posted one in this thread. :P/>
again, that requires a URL to be specified
1054 posts
Posted 15 January 2013 - 02:09 PM
You can easily write a funciton that does this for you.
there is no way to receive without specifying a URL with the given functions
http.listen does not specify which URL it is listening to
Actually, TheOriginalBit posted one in this thread. :P/>
again, that requires a URL to be specified
Eh, you can't listen for inbound connections you know. That would be bad… And you'd need to have some knowledge to make servers accept those inbound connections (especially when behind NAT). And just.. it's wrong…
404 posts
Location
St. Petersburg
Posted 15 January 2013 - 06:15 PM
how is it wrong? the only way it could be bad would be if someone executed text received from a website that magically was malicious lua bytecode that wasn't stopped by dan200's sandbox
871 posts
Posted 15 January 2013 - 06:39 PM
implementing a web server in lua running on a minecraft server is so self-evidently wrong I wouldn't even know where to begin explaining why it is wrong. Certainly not going to happen, though.
8543 posts
Posted 15 January 2013 - 06:49 PM
This doesn't even require one of the mod developers to No it.
No.