*** empty log message ***

This commit is contained in:
mpc
2004-07-24 03:31:24 +00:00
committed by zzz
parent f170ae741e
commit 3fd35a9c18
4 changed files with 99 additions and 10 deletions

View File

@@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: socket.cpp,v 1.7 2004/07/22 03:54:01 mpc Exp $
* $Id: socket.cpp,v 1.8 2004/07/22 22:08:20 mpc Exp $
*/
#include "platform.hpp"
@@ -35,10 +35,38 @@
#include "socket.hpp"
using namespace Libsockthread;
/*
* Closes the socket
*/
void Socket::close()
{
if (sock != SERR) {
if (close(sock) == -1)
; // FIXME log the error
}
sock = SERR;
}
/*
* Changes the address associated with the socket
*/
void Socket::set_addr(Socket_addr& addr)
{
close();
this->addr = addr;
setup_socket();
}
/*
* Prepares the socket for use
*/
void Socket::setup_socket()
{
assert(sock == SERR); // the descriptor shouldn't be active
if (!addr.is_ready())
throw Socket_error("Socket isn't ready");
throw Socket_error("Couldn't create socket: address isn't ready");
sock = socket(addr.get_family(), get_type(), 0);
sock = socket(addr.get_family(), addr.get_type(), 0);
if (sock == SERR)
throw Socket_error(strerror(errno));
}