Hello Tobias,

thanks for attaching your code. I think we're getting closer to the bug.
What is class LanAddress : Address { } used for? I don't understand it's
purpose. I've modified your code for the usage of TCP/IP. Note:
SocketType.RAW is for geeks only ;-).

Compile: dmd -m32 main.d ws2_32.lib
Usage: main.exe digitalmars.com

- mta`chrono
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;
}

Reply via email to