diff options
author | deva <deva> | 2005-05-03 08:31:58 +0000 |
---|---|---|
committer | deva <deva> | 2005-05-03 08:31:58 +0000 |
commit | 16aeeeb8110893e14c2d134542981cdc0f257411 (patch) | |
tree | fbcd9ec22c27d9f82a049055ec9d37035a1e3c03 /src/socket.cc | |
parent | a8456a6a949178ff06ca66cc10c0079da9f9f067 (diff) |
Removed the error object, and replaced it with a more generic info object.
Diffstat (limited to 'src/socket.cc')
-rw-r--r-- | src/socket.cc | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/src/socket.cc b/src/socket.cc index 351743c..4b282b4 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -8,43 +8,50 @@ ****************************************************************************/ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This file is part of MIaV. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ + /* * $Id$ */ + /* * $Log$ + * Revision 1.4 2005/05/03 08:31:59 deva + * Removed the error object, and replaced it with a more generic info object. + * * Revision 1.3 2005/05/01 09:56:26 deva * Added Id and Log tags to all files - * */ + #include <config.h> #include "socket.h" -Socket::Socket(Error* _err) +Socket::Socket(Info *ginfo) { - error = _err; + info = ginfo; connected = false; err = 0; } -Socket::Socket(u_short port, Error* _err) +Socket::Socket(u_short port, Info *ginfo) { - error = _err; + info = ginfo; connected = false; err = 0; @@ -56,9 +63,7 @@ Socket::Socket(u_short port, Error* _err) if (ssocket < 0) { err = 1; - char errbuf[] = "Socket: socket() failed!\0"; - if(error) error->pushError(errbuf); - else perror(errbuf); + info->error("Socket: socket() failed!"); } socketaddr.sin_family = AF_INET; // Use "internet protocol" IP @@ -81,9 +86,7 @@ Socket Socket::slisten() Socket s = Socket(); if(err) { - char errbuf[] = "Socket: No socket present!\0"; - if(error) error->pushError(errbuf); - else perror(errbuf); + info->error("Socket: No socket present!"); return s; } if(!connected) { @@ -91,7 +94,7 @@ Socket Socket::slisten() err = bind(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr)); if (err) { - perror("Socket: bind() failed"); + info->error("Socket: bind() failed!"); return s; } @@ -99,9 +102,7 @@ Socket Socket::slisten() // requests (max 5 in queue) err = listen(ssocket, 5); if(err) { - char errbuf[] = "Socket: listen() failed!\0"; - if(error) error->pushError(errbuf); - else perror(errbuf); + info->error("Socket: listen() failed!"); return s; } } @@ -115,9 +116,7 @@ Socket Socket::slisten() if (s.ssocket < 0) { err = 1; - char errbuf[] = "Socket: accept() failed!\0"; - if(error) error->pushError(errbuf); - else perror(errbuf); + info->error("Socket: accept() failed!"); return s; } @@ -130,7 +129,7 @@ Socket Socket::slisten() int Socket::sconnect(char *ip) { if(err) { - perror("Socket: No socket present"); + info->error("Socket: No socket present!"); return err; } @@ -140,9 +139,7 @@ int Socket::sconnect(char *ip) err = connect(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr)); if (err) { - char errbuf[] = "Socket: connect() failed!\0"; - if(error) error->pushError(errbuf); - else perror(errbuf); + info->error("Socket: connect() failed!"); return err; } // fprintf(stderr, "Socket connected\n"); |