Blockland Forums > Modification Help
Retrieving data from a webserver
Ipquarx:
--- Quote from: Port on April 05, 2012, 06:51:19 PM ---Which field are you talking about? Server or client?
--- End quote ---
Mostly the server, I'm okay with TCPObjects for the most part.
Port:
--- Quote from: Ipquarx on April 05, 2012, 07:12:28 PM ---Mostly the server, I'm okay with TCPObjects for the most part.
--- End quote ---
What language are you planning to use for it?
Destiny/Zack0Wack0:
--- Quote from: Ipquarx on April 05, 2012, 07:12:28 PM ---Mostly the server, I'm okay with TCPObjects for the most part.
--- End quote ---
Ruby
--- Code: ---require "socket"
port = 1234
server = TCPServer.new port
loop do
Thread.start(server.accept) do |client| # connected
client.puts "hi" # send data
loop do
msg = client.gets # receive data
end
end
end
--- End code ---
Node.js:
--- Code: ---var net = require("net");
var port = 1234;
net.createServer(function(client) {
client.write("hi"); // send data
client.on("data", function(msg) {
// received data
});
}).listen(port);
--- End code ---
Python
--- Code: ---import socketserver
class Handler(socketserver.BaseRequestHandler):
def handle(self):
request = self.request
request.send("hi")
msg = request.recv(1024)
if __name__ == "__main__":
port = 1234
server = SocketServer.TCPServer(("localhost", port), Handler)
server.serve_forever()
--- End code ---
Axolotl:
I recommend you use Python because it can interact with the system and is easy but the GUI interface of IDLE looks sort of bland.
Port:
--- Quote from: Axolotl on April 06, 2012, 03:59:58 AM ---I recommend you use Python because it can interact with the system and is easy but the GUI interface of IDLE looks sort of bland.
--- End quote ---
IDLE is not required to program in Python.