Register for your free account! | Forgot your password?

You last visited: Today at 22:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[D] Socket Help

Discussion on [D] Socket Help within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
[D] Socket Help

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.
Super Aids is offline  
Old 03/03/2013, 15:17   #2
 
elite*gold: 0
Join Date: Jan 2013
Posts: 40
Received Thanks: 29
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 ()
ShittyMod is offline  
Thanks
1 User
Old 03/03/2013, 15:33   #3
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
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
Super Aids is offline  
Reply




All times are GMT +1. The time now is 22:50.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.