Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'SocketConnection (./kdelibs/arts/mcop/socketconnection.h:32)
class SocketConnection :public Connection, public IONotify {
protected:
std::string serverID;
int fd;
bool _broken;
std::list<Buffer *> pending;
void writeBuffer(Buffer *buffer);
SocketConnection();
public:
SocketConnection(int fd);
void qSendBuffer(Buffer *buffer);
void notifyIO(int fd, int types);
void drop();
bool broken();
};
kdelibs'SocketConnection::SocketConnection() (./kdelibs/arts/mcop/socketconnection.cc:52)
SocketConnection::SocketConnection()
{
}
kdelibs'SocketConnection::SocketConnection() (./kdelibs/arts/mcop/socketconnection.cc:56)
SocketConnection::SocketConnection(int fd)
{
_broken = false;
printf("socketconnection created, fd = %d\n",fd);
this->fd = fd;
Dispatcher::the()->ioManager()->watchFD(fd,
IOType::read|IOType::except|IOType::reentrant,this);
initReceive();
}
kdelibs'SocketConnection::qSendBuffer() (./kdelibs/arts/mcop/socketconnection.cc:67)
void SocketConnection::qSendBuffer(Buffer *buffer)
{
if(_broken)
{
// forget it ;) - no connection there any longer
delete buffer;
return;
}
if(pending.size() == 0)
{
// if there is nothing pending already, it may be that we are lucky
// and can write the buffer right now without blocking
writeBuffer(buffer);
if(!buffer->remaining())
{
delete buffer;
return;
}
// but if it blocks, we'll need to watch for write chances to send
// that buffer later
Dispatcher::the()->ioManager()->watchFD(fd,IOType::write|IOType::reentrant,this);
}
pending.push_back(buffer);
}
kdelibs'SocketConnection::notifyIO() (./kdelibs/arts/mcop/socketconnection.cc:94)
void SocketConnection::notifyIO(int fd, int types)
{
assert(fd == this->fd);
if(types & IOType::read)
{
//printf("processing read notification\n");
unsigned char buffer[MCOP_MAX_READ_SIZE];
long n = read(fd,buffer,MCOP_MAX_READ_SIZE);
//printf("ok, got %ld bytes\n",n);
if(n > 0)
{
receive(buffer,n);
}
else if(n == 0 && errno != EAGAIN)
{
close(fd);
_broken = true;
Dispatcher::the()->ioManager()->remove(this,IOType::all);
Dispatcher::the()->handleConnectionClose(this);
// warning: the object may not exist any more here!
return;
}
}
if(types & IOType::write)
{
assert(pending.size() != 0);
Buffer *pbuffer = *pending.begin();
if(pbuffer->remaining()) writeBuffer(pbuffer);
// no else => it could have been sent in the if(..remaining..) above
if(!pbuffer->remaining())
{
delete pbuffer;
pending.pop_front();
if(pending.size() == 0)
Dispatcher::the()->ioManager()->remove(this,IOType::write);
}
}
if(types & IOType::except)
{
assert(false);
}
}
kdelibs'SocketConnection::writeBuffer() (./kdelibs/arts/mcop/socketconnection.cc:146)
void SocketConnection::writeBuffer(Buffer *buffer)
{
long len = MCOP_MAX_WRITE_SIZE;
if(buffer->remaining() < len) len = buffer->remaining();
void *data = buffer->peek(len);
long written = write(fd,data,len);
if(written > 0)
buffer->skip(len);
}
kdelibs'SocketConnection::broken() (./kdelibs/arts/mcop/socketconnection.cc:158)
bool SocketConnection::broken()
{
return _broken;
}
kdelibs'SocketConnection::drop() (./kdelibs/arts/mcop/socketconnection.cc:163)
void SocketConnection::drop()
{
if(!_broken)
{
close(fd);
_broken = true;
Dispatcher::the()->ioManager()->remove(this,IOType::all);
}
}