Loading...
Searching...
No Matches
IPv4Socket.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// IPv4Socket.h
//------------------------------------------------------------------------------
// Copyright (c) 1998 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef IPV4_SOCKET_Hh
#define IPV4_SOCKET_Hh
#include "assa/Socket.h"
#include "assa/Socketbuf.h"
namespace ASSA {
class IPv4Socket : public Socket
{
public:
static const int MAXTCPBUFSZ;
IPv4Socket()
: m_path (0), m_rdbuf (new Socketbuf (this)) {
trace_with_mask("IPv4Socket::IPv4Socket()",SOCKTRACE);
}
IPv4Socket(const handler_t fd_)
: m_path (0), m_rdbuf (new Socketbuf (this))
{
trace_with_mask("IPv4Socket::IPv4Socket(fd_)",SOCKTRACE);
m_fd = fd_; // inherited from the parent class
}
~IPv4Socket()
{
trace_with_mask("IPv4Socket::~IPv4Socket",SOCKTRACE);
this->close ();
if (m_rdbuf != 0) {
delete m_rdbuf;
}
}
IPv4Socket* clone () const;
bool open(const int domain_);
bool close();
bool connect(const Address& address_);
virtual bool bind (const Address& my_address_);
IPv4Socket* accept ();
int read (char* buf_, const unsigned int size_);
int write (const char* buf_, const unsigned int size_);
handler_t getHandler () const { return m_fd; }
const int getDomain () const { return m_type; }
virtual Streambuf* rdbuf () { return m_rdbuf; }
virtual Streambuf* rdbuf (Streambuf* sb_);
virtual int in_avail () const { return m_rdbuf->in_avail (); }
private:
// No copying
IPv4Socket (const IPv4Socket&);
IPv4Socket& operator= (const IPv4Socket&);
private:
char* m_path;
Streambuf* m_rdbuf;
};
} // end namespace ASSA
#endif // IPV4_SOCKET_Hh
trace_with_mask
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
Socket.h
Abstraction of socket data type.
Socketbuf.h
Socketbuf class is derived from Streambuf to provide I/O with the socket file descriptor.
ASSA::Address
Definition Address.h:51
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::IPv4Socket
Definition IPv4Socket.h:26
ASSA::IPv4Socket::accept
IPv4Socket * accept()
Accept connection on the listening socket.
Definition IPv4Socket.cpp:177
ASSA::IPv4Socket::write
int write(const char *buf_, const unsigned int size_)
Perform blocking write by writing packet of specified size.
Definition IPv4Socket.cpp:294
ASSA::IPv4Socket::IPv4Socket
IPv4Socket(const handler_t fd_)
Constructor from file descriptor.
Definition IPv4Socket.h:40
ASSA::IPv4Socket::IPv4Socket
IPv4Socket()
Default constructor.
Definition IPv4Socket.h:32
ASSA::IPv4Socket::clone
IPv4Socket * clone() const
"Virtual constructor".
Definition IPv4Socket.cpp:330
ASSA::IPv4Socket::rdbuf
virtual Streambuf * rdbuf()
Return a pointer to the Socketbuf associated with the stream.
Definition IPv4Socket.h:146
ASSA::IPv4Socket::close
bool close()
Close socket connection.
Definition IPv4Socket.cpp:66
ASSA::IPv4Socket::connect
bool connect(const Address &address_)
Client makes connection with the server at address_.
Definition IPv4Socket.cpp:93
ASSA::IPv4Socket::open
bool open(const int domain_)
Create socket.
Definition IPv4Socket.cpp:42
ASSA::IPv4Socket::m_rdbuf
Streambuf * m_rdbuf
Socketbuf.
Definition IPv4Socket.h:176
ASSA::IPv4Socket::in_avail
virtual int in_avail() const
This function returns the number of characters immediately available in the get area of the underlyin...
Definition IPv4Socket.h:162
ASSA::IPv4Socket::bind
virtual bool bind(const Address &my_address_)
Server binds listening socket to its local well-known port.
Definition IPv4Socket.cpp:124
ASSA::IPv4Socket::getDomain
const int getDomain() const
Get socket domain type.
Definition IPv4Socket.h:138
ASSA::IPv4Socket::IPv4Socket
IPv4Socket(const IPv4Socket &)
ASSA::IPv4Socket::read
int read(char *buf_, const unsigned int size_)
Read packet of specified size and save it to the given buffer.
Definition IPv4Socket.cpp:231
ASSA::IPv4Socket::getHandler
handler_t getHandler() const
Get socket file descriptor.
Definition IPv4Socket.h:135
ASSA::IPv4Socket::m_path
char * m_path
Path of UNIX domain socket.
Definition IPv4Socket.h:173
ASSA::IPv4Socket::operator=
IPv4Socket & operator=(const IPv4Socket &)
ASSA::IPv4Socket::~IPv4Socket
~IPv4Socket()
Destructor will close connection.
Definition IPv4Socket.h:49
ASSA::IPv4Socket::MAXTCPBUFSZ
static const int MAXTCPBUFSZ
Maximum TCP data frame (no options)
Definition IPv4Socket.h:29
ASSA::Socket
Definition Socket.h:71
ASSA::Socket::m_type
int m_type
Socket domain type.
Definition Socket.h:488
ASSA::Socket::m_fd
handler_t m_fd
File descriptor.
Definition Socket.h:485
ASSA::Socketbuf
Definition Socketbuf.h:30
ASSA::Streambuf
Streambuf class.
Definition Streambuf.h:91
ASSA::Streambuf::in_avail
int in_avail()
This function returns the number of characters immediately available in the get area.
Definition Streambuf.h:399
ASSA
Definition Acceptor.h:40
ASSA::SOCKTRACE
@ SOCKTRACE
Extended Socket & friends messages
Definition LogMask.h:42