Elements Technologies

Internet Pack

A cross-platform TCP/IP library for building network clients and servers.

Built on TCP/IP

Internet Pack includes components for standard protocols such as HTTP, FTP, SMTP, and POP3. Its reusable connection classes also let you implement your own TCP/IP protocols.

The library is available for all Elements target platforms and can be used alongside Elements RTL in cross-platform projects.

Serve a File over HTTP

Create an Elements console project for any target and add a reference to RemObjects.InternetPack. Put an index.html file inside a www folder in the program’s working directory.

Oxygene
namespace HttpServerExample;

uses
  RemObjects.InternetPack.Http;

type
  Program = class
  public

    class method Main;
    begin
      var lServer := new SimpleHttpServer;
      lServer.RootPath := "www";
      lServer.Port := 8080;
      lServer.Open;
      readLn;
      lServer.Close;
    end;

  end;

end.
Myth
version 1;
use RemObjects.InternetPack.Http;

type Program: class {
  static method Main(): Int32! {
    using _server = new SimpleHttpServer() {
      _server.RootPath = "www";
      _server.Port = 8080;
      _server.Open();
      readLn();
    }
    return 0;
  }
}
C#
using RemObjects.InternetPack.Http;

static class Program
{
    static void Main()
    {
        var server = new SimpleHttpServer();
        server.RootPath = "www";
        server.Port = 8080;
        server.Open();
        readLn();
        server.Close();
    }
}
Python
from RemObjects.InternetPack.Http import SimpleHttpServer

server = SimpleHttpServer()
server.RootPath = "www"
server.Port = 8080
server.Open()
readLn()
server.Close()
Java
import RemObjects.InternetPack.Http.*;

class Program {
    public static void main(String[] args) {
        SimpleHttpServer server = new SimpleHttpServer();
        server.RootPath = "www";
        server.Port = 8080;
        server.Open();
        readLn();
        server.Close();
    }
}
Go
package main

import "RemObjects.InternetPack.Http"

func main() {
    server := RemObjects.InternetPack.Http.SimpleHttpServer{}
    server.RootPath = "www"
    server.Port = 8080
    server.Open()
    readLn()
    server.Close()
}
Swift
import RemObjects.InternetPack.Http

public class Program {
    public static func Main() {
        let server = SimpleHttpServer()
        server.RootPath = "www"
        server.Port = 8080
        server.Open()
        _ = readLn()
        server.Close()
    }
}
Mercury
Imports RemObjects.InternetPack.Http

Module Program
    Sub Main()
        Dim server As New SimpleHttpServer()
        server.RootPath = "www"
        server.Port = 8080
        server.Open()
        readLn()
        server.Close()
    End Sub
End Module

Fetch the File from a Client

With the server running, use this snippet inside another console project with the same references and the RemObjects.InternetPack.Http namespace in scope.

Oxygene
var lClient := new HttpClient;
writeLn(lClient.Get("http://127.0.0.1:8080/index.html"));
Myth
using _client = new HttpClient() {
  writeLn(_client.Get("http://127.0.0.1:8080/index.html"));
}
C#
var client = new HttpClient();
writeLn(client.Get("http://127.0.0.1:8080/index.html"));
Python
client = HttpClient()
writeLn(client.Get("http://127.0.0.1:8080/index.html"))
Java
HttpClient client = new HttpClient();
writeLn(client.Get("http://127.0.0.1:8080/index.html"));
Go
client := RemObjects.InternetPack.Http.HttpClient{}
writeLn(client.Get("http://127.0.0.1:8080/index.html"))
Swift
let client = HttpClient()
writeLn(client.Get("http://127.0.0.1:8080/index.html"))
Mercury
Dim client As New HttpClient()
writeLn(client.Get("http://127.0.0.1:8080/index.html"))

The Engine Behind ESP (and This Website)

Internet Pack supplies the networking layer for the built-in web server used by Elements Server Pages. You can also use it directly for your own clients and servers.

Open Source

Browse the source and samples on GitHub .