summaryrefslogtreecommitdiff
path: root/i/simulotron
diff options
context:
space:
mode:
authorhaller2005-12-02 00:40:03 +0000
committerhaller2005-12-02 00:40:03 +0000
commit8becc9cd13865719346d029a263e9ad4143915c6 (patch)
treeba1aee1b353a20da8b12c2df92d9159bcdbca694 /i/simulotron
parentab21fd007709cc4103bbdbe6dc9360b71475a01b (diff)
Mise à jour du configure.ac
Correction des flags et libs pour test_socket modification de socket (problèmes à résoudre)
Diffstat (limited to 'i/simulotron')
-rw-r--r--i/simulotron/configure.ac6
-rw-r--r--i/simulotron/src/socket/Makefile.incl.am3
-rw-r--r--i/simulotron/src/socket/socket.cc22
-rw-r--r--i/simulotron/src/socket/socket.hh4
4 files changed, 29 insertions, 6 deletions
diff --git a/i/simulotron/configure.ac b/i/simulotron/configure.ac
index 86f89cf..448cfa5 100644
--- a/i/simulotron/configure.ac
+++ b/i/simulotron/configure.ac
@@ -6,6 +6,7 @@ AC_INIT(simulotron, 2006.0.01, APBTeam <si2e@efrei.fr>)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_CONFIG_SRCDIR([src/main.cc])
+AC_CONFIG_HEADER([src/config.h])
CXXFLAGS=
@@ -16,14 +17,15 @@ AC_PROG_CXX
# Checks for libraries.
# Checks for header files.
-AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
+AC_C_INLINE
# Checks for library functions.
-AC_CHECK_FUNCS([socket])
+AC_CHECK_FUNCS([gethostbyaddr gethostbyname inet_ntoa socket strerror])
AC_CONFIG_FILES([Makefile
diff --git a/i/simulotron/src/socket/Makefile.incl.am b/i/simulotron/src/socket/Makefile.incl.am
index a554b58..0cbe7bc 100644
--- a/i/simulotron/src/socket/Makefile.incl.am
+++ b/i/simulotron/src/socket/Makefile.incl.am
@@ -3,4 +3,5 @@ socket_S = socket/socket.cc socket/socket.hh $(address_S) $(errno_exception_S)
check_PROGRAMS += test_socket
test_socket_SOURCES = socket/test_socket.cc $(socket_S)
-test_socket_LDFLAGS = -pthread
+test_socket_CXXFLAGS = -pthread -g -W -Wall
+test_socket_LDADD = -lpthread
diff --git a/i/simulotron/src/socket/socket.cc b/i/simulotron/src/socket/socket.cc
index b696690..0e7f819 100644
--- a/i/simulotron/src/socket/socket.cc
+++ b/i/simulotron/src/socket/socket.cc
@@ -22,10 +22,22 @@ Socket::Socket(int socket)
socket_ = socket;
}
+Socket::Socket(Socket & socket)
+{
+ socket_ = socket.socket_;
+ socket.socket_ = -1;
+}
+
Socket::~Socket(void)
{
- // XXX Pas faisable car les copy dtruise les socket
- //close(socket_);
+ if(socket_ >= 0)
+ ::close(socket_);
+}
+
+Socket & Socket::operator= (Socket & socket)
+{
+ socket_ = socket.socket_;
+ socket.socket_ = -1;
}
void Socket::connect(const Address & address)
@@ -46,7 +58,6 @@ Socket Socket::accept(Address & address)
socklen_t length = sizeof(sockaddr_in);
int socket = ::accept(socket_, &addr, &length);
-
if (socket < 0)
throw errno_exception("Chaussette bloqu la douane", errno);
address = Address(&addr, length);
@@ -104,3 +115,8 @@ void Socket::putChar(char c)
{
::write(socket_, &c, 1);
}
+
+int Socket::getFD(void)
+{
+ return socket_;
+}
diff --git a/i/simulotron/src/socket/socket.hh b/i/simulotron/src/socket/socket.hh
index 3d054fa..92fddfd 100644
--- a/i/simulotron/src/socket/socket.hh
+++ b/i/simulotron/src/socket/socket.hh
@@ -14,8 +14,12 @@ class Socket
Socket(const Address & address);
/// Constructeur partir d'un fd
Socket(int socket);
+ /// Constructeur par recopie
+ Socket(Socket & socket);
/// Destructeur
~Socket(void);
+ /// operateur d'affectation
+ Socket & operator= (Socket & socket);
/// Connect le client au serveur
void connect(const Address & address);
/// Ecoute le port