Author Topic: Retrieving data from a webserver  (Read 1680 times)

Which field are you talking about? Server or client?
Mostly the server, I'm okay with TCPObjects for the most part.

Mostly the server, I'm okay with TCPObjects for the most part.

What language are you planning to use for it?

Mostly the server, I'm okay with TCPObjects for the most part.
Ruby
Code: [Select]
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

Node.js:
Code: [Select]
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);

Python
Code: [Select]
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()

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.

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.

IDLE is not required to program in Python.

-snip-
Then i'd just put out a listener TCPObject for that port?

Then i'd just put out a listener TCPObject for that port?
Yes. But depending on where you upload it, you have to bind it to a port you are given.