The server closed restart the listen port again

Aug 18, 2015 at 8:51 AM
Edited Aug 25, 2015 at 3:21 AM
Hi all,
  There are some problems when I write a http server in linux with http_listener,the follow code will show the problem, if I register a new listener[ listener.open() ], the listener  unregistered   will register again ,in windows 
have no uch problem,the code it like this:

int main()
{
for (int i = 6800; i<6803; i++)
{
    cout << "please input IP Address" << endl;
    char szUrl[100] = { 0 };
    sprintf(szUrl, "http://192.168.139.202:%d/abcdef", i);
    cout << szUrl << endl;
    http_listener listener(szUrl);
    listener.support(web::http::methods::GET, [](web::http::http_request request) {

    }
    );

    listener.open();

    if (i != 6802) {
        listener.close();
    }
}
return 0;

why the last port restart again,the netstat show like this:

tcp 0 0 192.168.139.202:6800 0.0.0.0:* LISTEN -
tcp 0 0 192.168.139.202:6801 0.0.0.0:* LISTEN -
tcp 0 0 192.168.139.202:6802 0.0.0.0:* LISTEN

I am sure when listener.close() is called the port stop listenning, but a new call listener.open() will start all port previous。Did anyone meet the same problem?How to solve it? Thank you!