Re: Server is not active?
On Sunday, 29 September 2013 at 15:25:53 UTC, ollie wrote: When you instantiate your InternetAddress class, set it to the assigned IP of your server machine. It's starting to look like more of a network configuration problem and not a D.learn problem. I'd rather not pollute this forum with those type of issues. Good luck. I'll do my best. Thank you.
Re: Server is not active?
On Saturday, 28 September 2013 at 05:28:05 UTC, ollie wrote: On Fri, 27 Sep 2013 03:22:32 +0200, wagtail wrote: A part of code shown below. /++ Server main() / ushort port = 9876; auto inet = new InternetAddress(0.0.0.0,port); Socket server = new TcpSocket(inet.addressFamily()); bool flag = true; server.bind(inet); server.listen(255); Is there any particular reason to use 0.0.0.0 creating your InternetAddress? I think it should be the ip of your server or just send port and ADDR_ANY will be used. From Wikipedia: In the Internet Protocol version 4 the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non applicable target. Thank you for your reply! I thought ADDR_ANY is the same as 0.0.0.0,so I used it. This Server doesn't know ip of opponent client. I tried rewriting code with using ADDR_ANY, but do not work...
Re: Server is not active?
On Saturday, 28 September 2013 at 17:13:06 UTC, ollie wrote: Try something like this: auto inet = new InternetAddress(port); Oh,I'm sorry. I forgot writing I already tried above instance. The constructor for class InternetAddress will set addr to ADDR_ANY. This should work if your server and client are on the same machine. Otherwise you need to set the address to the IP of your server. When my server and client are on the same machine,these succeed. If I try communicating with other machine via global network,it do not work. IP of my server which you say above should set to server side?
Re: Server is not active?
On Saturday, 28 September 2013 at 23:25:20 UTC, Kapps wrote: This is just a guess, but it is because you're setting the socket to be blocking after the call to accept? If it defaults to non-blocking, this would cause accept to return immediately, so the client connecting would fail as the server isn't currently accepting connections. Also to verify it's not a firewall issue, for connecting try using 127.0.0.1. Thank you for your reply:) Seeing your reply, I try commenting client.blocking(true) out, but it do not work. My server and client do work using 127.0.0.1, So ,maybe I think firewall setting is correct.
Server is not active?
I tried making simple chat program with std.socket. On starting programs,client program stops. SocketOSException was caught ,so I checked errorCode(). Win7,which I use,tells me error code 10061. I surely think to start server program, and I allow fire wall to connect... Is there any possible causes else?
Re: Server is not active?
On Friday, 27 September 2013 at 01:04:47 UTC, Adam D. Ruppe wrote: Can you show us any more code? A part of code shown below. /++ Server main() / ushort port = 9876; auto inet = new InternetAddress(0.0.0.0,port); Socket server = new TcpSocket(inet.addressFamily()); bool flag = true; server.bind(inet); server.listen(255); titleMes();//show titleMessage while(flag){ Socket client; printf(WaitingConnection...); try{ client = server.accept(); client.blocking(true); }catch(SocketAcceptException){ printf(acceptEx...); } myTasks.add(new Task(client,(mesLog.add))); //Task : Thread class containing Socket. flag = false; printf(need more connection? y,n); char[] yn; yn = cast(char[])readln(); if(yn[0]=='y')flag = true; else { foreach(Task t;myTasks.getArray)t.start(); foreach(Task t;myTasks.getArray)t.getTarget_p().send(OK); } } int old=0; while(1){ for(int i=0;i1;i++){for(int j=0;j1;j++){}} system(cls); foreach(char[] c;mesLog.getArray)writeln(c); } } /+ client main() / Socket target; //Listener is Thread continuing to do listen(). Listener listener; auto INET_OWN = new InternetAddress(InternetAddress.PORT_ANY); char[] address; ushort port = 9876; InternetAddress INET_DES; titleMes(); writeln(Please input destination ipAddress.(IPv4)(ex:218.112.218.204)); address = readln().dup; write(target : ); writeln(address); INET_DES = new InternetAddress(address,port); target = new TcpSocket(/*INET_OWN.addressFamily()*/); //connection try{ target.connect(INET_DES); }catch(SocketOSException e){ printf(Errorcode%d\n,e.errorCode); if(e.errorCode==10061)writeln(Server is not available\n); } ..
Re: Server is not active?
On Friday, 27 September 2013 at 01:37:38 UTC, Adam D. Ruppe wrote: hmm, I don't know what the problem is, the socket stuff there looks correct... will have to wait for someone else to have ideas. Thank you for your reply. I'll think it over again.