[D] Socket Help

03/03/2013 14:13 Super Aids#1
Can someone tell me why this does not work?
Code:
		Address[] addresses = getAddress(addrStr, Port);
		foreach (addr; addresses) // never runs this loop as there is no addresses
			writeln(addr.toAddrString()); // :(
addrStr is a string and Port is ushort.

addrStr is set to 127.0.0.1 and Port to 8877.

For some reason there is no addresses returned.

I'm already having a debugger. It seems like it calls "getAddress()", although it does not return anything :s

#Edit okay now it returns the address, however it fails at bind.
Code:
serverSocket.bind(addresses[0]);
And I can't call:
Code:
writeln("Address: ", addresses[0].toAddrString());
But I can call:
Code:
writeln("Address: ", addresses[0].name);
This is really bugging me.

serverSocket is TcpSocket btw.

Tried using this as well:
Code:
InternetAddress inetaddr = new InternetAddress(addrStr, Port);
And then bind(inetaddr) which doesn't work either.
03/03/2013 15:17 ShittyMod#2
getAddress is used to translate from hostname to IP. I have no idea why it's not working for you though, getAddress("127.0.0.1", 8877) does return an Address [127.0.0.1:8877] here.

How I listen for connections using the std.socket library is something like:

Code:
	TcpSocket socket = new TcpSocket(AddressFamily.INET);
	socket.blocking = true;
	socket.bind(new InternetAddress("127.0.0.1", 3389));
	
	socket.listen(1);
	
	while(true)
	{
		
		Socket client = socket.accept;
		
	}
I'd rather use the vibe library though ([Only registered and activated users can see links. Click Here To Register...])
03/03/2013 15:33 Super Aids#3
Yeah I already fixed it myself like 10 mins ago.

Found out it was a problem with my debugger though, it didn't add the libraries for windows. Although when I ran without debugger it worked xD