Why I need to restart the editor in order to run the game as host by using FSocket?

I use FSocket to build connection and make my game run as host.
I click “play” to test the game and it works and do get connecton.
But after that, if I want to test my game again ,
I need to restart the editor otherwise the accept function will not wait for connection but return NULL directly.
How does it come? Is there any wrong with my code? Btw: I have closed the sock before I close the game.
Below are how I build connection :

  FSocket* lisock;
    lisock = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false);
    
    int32 port = 1111;
    TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
    
    addr->SetIp(FIPv4Address::Any.GetValue());
    addr->SetPort(port);
    
    lisock->Bind(*addr);
    lisock->Listen(8);
    
    TSharedRef<FInternetAddr> conaddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
    
    FSocket* consock;
    consock = lisock->Accept(*conaddr, TEXT(""));

Are you closing the socket when the game shuts down?
Also, this may help:

lisock.SetReuseAddr();

It works~thank you.
I did not close the lisock when I shut down because it will crash if I do not connect to the game.
I modify my code and it can be closed without problem.