In previous versions 4.6 and below when the connection to ports were closed in code. E.g when an actor is destroyed the port could then be reused by the same actor in a different level for example. However in 4.7 this now no longer works. The ports when using .Close() in code seems now not to close the connection.
Has anyone else had this problem had this problem?
Could you elaborate on your issue for me? What ports are you referring to? How are you using Close()? Could you provide an example of what you’re seeing or steps to follow to reproduce this on our end?
I have some custom C++ plugin, which acts as a TCP receiver attached to an actor. A TCP blueprint derived from the plugin is created which (for the sake of example) prints received data from a selected port and address. On each level blueprint a TCP initializer box is run on level startup. What should happen is that the tcp connection is destroyed when changing maps this would free up the port.
Now the plugin’s creator has told me that in previous versions of UE4 the plugin has worked perfectly.
For example, with the previous set up; I have an external program, which pipes data to UE4 on a set address and port. When I play a level data is printed which is what I expect. However when I change map I would expect the same behavior to happen, data being printed. However this isn’t the case.
Below is the EndPlay method of the plugin:
void ATCPReceiver::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
//~~~~~~~~~~~~~~~~
//Clear all sockets!
// makes sure repeat plays in Editor doesn’t hold on to old sockets!
if(ListenerSocket)
{
ListenerSocket->Close();
ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ListenerSocket);
}
if(ConnectionSocket)
{
ConnectionSocket->Close();
ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(ConnectionSocket);
}
}
I have confirmed that this code is being executed by printing log messages before and after the close lines. So I am confident that this method is being executed.
I have emailed the plugin’s creator to ask exactly which version of UE4 the plugin works perfectly as should do mentioned above but I have looked on GitHub at previous versions Close() methods in the engine and I can’t see much of a difference from previous version and 4.7.3.
Unfortunately we are not able to provide support for plugins created by another user. If is able to update his plugin to work with 4.7, it should also resolve the issue you are experiencing. If you continue to have trouble after the plugin is updated, we can try to find out what is happening (if it is something happening between the Engine and the plugin, may need to get in touch with us to resolve it).
I will mark this post as resolved for now, but it can be re-opened later if necessary.