From 87e2e08ed7b47f30e458736dbfbb1ede75349d40 Mon Sep 17 00:00:00 2001 From: haller Date: Mon, 28 Nov 2005 00:55:32 +0000 Subject: Deux trois modif sur l'A/A Bidouillage des socket, ca compile mais c'est tout --- i/simulotron/src/socket/socket.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'i/simulotron/src/socket/socket.cc') diff --git a/i/simulotron/src/socket/socket.cc b/i/simulotron/src/socket/socket.cc index 2f7139c..f231cf5 100644 --- a/i/simulotron/src/socket/socket.cc +++ b/i/simulotron/src/socket/socket.cc @@ -1,6 +1,10 @@ #include +#include +#include "socket/socket.hh" +#include "utils/errno_exception.hh" +#include "socket/address.hh" -Socket::Socket(const std::string & address, int port, bool block) +Socket::Socket(const Address & address) { // Crée le file descriptor du socket socket_ = socket (PF_INET, SOCK_STREAM, 0); @@ -8,19 +12,24 @@ Socket::Socket(const std::string & address, int port, bool block) throw errno_exception ("La chaussette n'a pas pu être tricoté", errno); // On bind le socket - if(bind (socket_, address.getSockaddr(), sizeof(*address.getSockaddr())) < 0) + if(::bind (socket_, address.getSockaddr(), sizeof(*address.getSockaddr())) < 0) throw errno_exception("Impossible d'assigner la chausette", errno); } +Socket::Socket(int socket) +{ + socket_ = socket; +} + void Socket::connect(const Address & address) { - if (connect (socket_, address.getSockaddr(), sizeof(*address.getSockaddr()) < 0)) + if (::connect (socket_, address.getSockaddr(), sizeof(*address.getSockaddr()) < 0)) throw errno_exception("Impossible de mettre la chaussette", errno); } void Socket::listen(int maxQueue) { - if( listen(socket_, maxQueue) < 0 ) + if(::listen(socket_, maxQueue) < 0 ) throw errno_exception("Impossible d'écouter la mer dans la chaussette", errno); } @@ -29,11 +38,11 @@ Socket Socket::accept(Address & address) sockaddr addr; socklen_t length; - int socket = accept(socket_, &addr, &length); + int socket = ::accept(socket_, &addr, &length); if (socket < 0) throw errno_exception("Chaussette bloqué à la douane", errno); - address = Address(addr, length); + address = Address(&addr, length); return Socket(socket); } -- cgit v1.2.3