Fixed TcpListener and TcpSocket not behaving as documented when calling listen or connect while the underlying socket object already exists, also adjusted UdpSocket to be consistent with connect and listen behaviour when calling bind while the underlying socket object already exists. Fixes #1346

This commit is contained in:
binary1248 2018-04-08 04:42:56 +02:00 committed by Lukas Dürrenberger
parent 9da895da8b
commit 9bdd6d46dd
6 changed files with 24 additions and 7 deletions

View file

@ -63,6 +63,9 @@ unsigned short TcpListener::getLocalPort() const
////////////////////////////////////////////////////////////
Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address)
{
// Close the socket if it is already bound
close();
// Create the internal socket if it doesn't exist
create();

View file

@ -118,6 +118,9 @@ unsigned short TcpSocket::getRemotePort() const
////////////////////////////////////////////////////////////
Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout)
{
// Disconnect the socket if it is already connected
disconnect();
// Create the internal socket if it doesn't exist
create();

View file

@ -66,6 +66,9 @@ unsigned short UdpSocket::getLocalPort() const
////////////////////////////////////////////////////////////
Socket::Status UdpSocket::bind(unsigned short port, const IpAddress& address)
{
// Close the socket if it is already bound
close();
// Create the internal socket if it doesn't exist
create();