import std.socket; import std.stdio; import std.string; import std.conv; int main(string[] args) { // declaration string host; ushort port = 80; // set correct host if(args.length > 1) { host = args[1]; } else { write("Connect to: "); host = readln().chop(); } // create addr and socket InternetAddress address = new InternetAddress(host, 80); Socket socket = new Socket(AddressFamily.INET, SocketType.STREAM); // print target writeln("connecting '", address.toString(), "'"); // connect to address socket.connect(address); // sending socket.send("GET /\r\n\r\n"); // receiving char buffer[1024]; uint size = socket.receive(buffer); writeln("ansered: '", buffer[0..size], "'"); // all done, no error return 0; }