On Saturday, 6 April 2019 at 03:24:04 UTC, FrankLike wrote:
Hi,everyone,...
Do you have some better code than this?
----------------------------------------------------------------
import std.stdio;
import std.socket;
void main()
{
testIPPort();
}
bool testIPPort()
{
try
{
auto results =
getAddressInfo("127.0.0.1",AddressInfoFlags.NUMERICHOST);
auto sock = new Socket(results[0]);
auto address = getAddress("127.0.0.1",8080);
sock.connect(address[0]);
writeln(address," connect ok");
return true;
}
catch(SocketException e)
{ return false;
}
}
---------------------------------------
Thanks.