Howto catch SocketOSException?

Jolly James via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 25 17:34:03 PDT 2017


How do you catch an std.socket.SocketOSException?


The following does not work, as the exception occurs anyway and 
leads to a crash:

>import ae.net.asockets;
>
>void main(string[] args)
>{
>	TcpServer tcp = new TcpServer();
>
>	try
>	{
>		tcp.listen(2345, "127.0.0.1c");
>		// '...c' makes the IP address invalid
>	}
>	catch (std.socket.SocketOSException e)
>	{
>		return;
>	}
>	catch (Exception e)
>	{
>		return;
>	}
>
>	socketManager.loop();
>}

Output:
>std.socket.SocketOSException at std\socket.d(975): getaddrinfo 
>error: Unknown Host


More information about the Digitalmars-d-learn mailing list