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:
parent
9da895da8b
commit
9bdd6d46dd
6 changed files with 24 additions and 7 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue