/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_NETEXCEPTIONS_HPP
#define NMM_NETEXCEPTIONS_HPP NMM_NETEXCEPTIONS_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/Exception.hpp"

namespace NMM {

  /** Exception for transmissions
   */
  class TransmissionException : public Exception {
  public:
    /** Constructor
     *
     * @param comment error string
     * @param my_errno error code
     */
    TransmissionException(const std::string& comment, int my_errno) : Exception(comment), errno_code(my_errno) {};

    /** Destructor
     */
    ~TransmissionException() {};
    const int errno_code;
  };

  /** Exception for connections
   */
  class ConnectionException : public Exception {
  public:
    enum ConnectionMethod{socket = 0, connect, close, open, shutdown, accept, listen, bind};
    /** Constructor
     *
     * @param comment error string
     * @param my_errno error code
     * @param cm kind of network interaction 
     */
    ConnectionException(const std::string& comment, int my_errno, ConnectionMethod cm) : Exception("ConnectionException >" + comment), errno_code(my_errno), method_code(cm) {}

    /** Destructor
     */
    ~ConnectionException() {};
    const int errno_code;
    const ConnectionMethod method_code;
  };

  class ConnectionClosed : public Exception {
  public:
    /** Constructor
     *
     * @param _errno error code
     */
    ConnectionClosed(int _errno)
      : Exception("Connection Closed by remote host"), errno_code(_errno) {}

    /** Destructor
     */
    ConnectionClosed(const std::string& msg, int _errno) : Exception (msg), errno_code(_errno) {}

    const int errno_code;
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
