From 16d986c762e97bc0cf0f0663f5f7a27dbdbbadca Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Sun, 17 Oct 2010 21:20:36 +0000 Subject: [PATCH] Binding two sockets to the same port on the same computer now triggers an error git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1584 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Network/Socket.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/SFML/Network/Socket.cpp b/src/SFML/Network/Socket.cpp index 382b54548..a5d49217f 100644 --- a/src/SFML/Network/Socket.cpp +++ b/src/SFML/Network/Socket.cpp @@ -99,17 +99,10 @@ void Socket::Create(SocketHandle handle) // Set the current blocking state SetBlocking(myIsBlocking); - // To avoid the "Address already in use" error message when trying to bind to the same port - int yes = 1; - if (setsockopt(mySocket, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&yes), sizeof(yes)) == -1) - { - Err() << "Failed to set socket option \"SO_REUSEADDR\" ; " - << "binding to a same port may fail if too fast" << std::endl; - } - if (myType == Tcp) { // Disable the Nagle algorithm (ie. removes buffering of TCP packets) + int yes = 1; if (setsockopt(mySocket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&yes), sizeof(yes)) == -1) { Err() << "Failed to set socket option \"TCP_NODELAY\" ; " @@ -119,6 +112,7 @@ void Socket::Create(SocketHandle handle) else { // Enable broadcast by default for UDP sockets + int yes = 1; if (setsockopt(mySocket, SOL_SOCKET, SO_BROADCAST, reinterpret_cast(&yes), sizeof(yes)) == -1) { Err() << "Failed to enable broadcast on UDP socket" << std::endl;