I try a simple application.
import vibe.d;
void kök(HTTPServerRequest istek, HTTPServerResponse yanıt)
{
yanıt.writeBody("Merhaba, Dünya!");
}
void main()
{
auto ayarlar = new HTTPServerSettings;
ayarlar.port = 8080;
ayarlar.bindAddresses = ["::1", "127.0.0.1"];
listenHTTP(ayarlar, &kök);
logInfo("Lütfen tarayıcınızda http://127.0.0.1:8080/ adresini açınız.");
runApplication();
}
It works as expected for the first time. But when I close the application using Ctrl-D or Ctrl-Z key combination I get an error like this.
Running ./ilk
Failed to listen on ::1:8080
Failed to listen on 127.0.0.1:8080
object.Exception@/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d(2090): Failed to listen for incoming HTTP connections on any of the supplied interfaces.
----------------
/usr/include/dmd/phobos/std/exception.d:515 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x55d927401182]
/usr/include/dmd/phobos/std/exception.d:436 pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x55d92741cd2e]
/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d:2090 @safe vibe.http.server.HTTPListener vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) @safe) [0x55d9274a4c30]
/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d:103 @safe vibe.http.server.HTTPListener vibe.http.server.listenHTTP!(vibe.http.server.HTTPServerSettings).listenHTTP(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) @safe) [0x55d9274019e9]
/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d:147 vibe.http.server.HTTPListener vibe.http.server.listenHTTP!(vibe.http.server.HTTPServerSettings).listenHTTP(vibe.http.server.HTTPServerSettings, void function(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)*) [0x55d92740190a]
source/app.d:15 _Dmain [0x55d927400e6c]
Program exited with code 1
If I change the port number (let's say 8081) and run it a second time it works as expected.
Netstat output is as follows :
$ sudo netstat -nlp | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:* DİNLE 3240/./ilk
tcp6 0 0 ::1:8080 :::* DİNLE 3240/./ilk
The name of the program is "ilk".