epclient.cc
/* ----------------------------------------------------------
epclient.cc by biscuit@actoz.com
for Linux 2.6.x
v1.0 06/19/2004 first release
---------------------------------------------------------- */
#include <unistd.h>
#include <iostream>
#include "epsocket.h"
#include "epclient.h"
using namespace std;
int TClient::OnRead(void)
{
char buf[1024];
int nread, nwrite;
nread = read(fd, buf, 1024);
if(nread == 0) return EP_ERROR_READ_CLOSE;
else if(nread < 0) return EP_ERROR_READ_GEN;
// »ùÇÃÀ̶ó ÀÌ°÷¿¡ ±×³É ¹Ù·Î echo Çϵµ·Ï Çß´Ù.
nwrite = write(fd, buf, nread);
if(nwrite < 1) return EP_ERROR_WRITE_GEN;
return EP_ERROR_NONE;
};
// 0 ÀÌÇÏÀÇ °ªÀ» ¸®ÅÏÇϸé, ¸®ÅÏ°ªÀÌ ±×´ë·Î OnError·Î Àü´ÞµÈ´Ù
int TClient::OnWrite(void)
{
// ³ªÁß¿¡ SendBuffering ¹æ½ÄÀ¸·Î °íÄ¥°ÍÀ̸ç, ÀÌ °÷¿¡¼ ½ÇÁ¦ flush¸¦ ÇØÁÖ¾î¾ß ÇÑ´Ù.
return EP_ERROR_NONE;
};
int TClient::OnError(const int nerror)
{
// Áö±ÝÀº ¾Æ¹«Ã³¸®µµ ¾Ê°í ±×³É ¸®ÅÏÇÑ´Ù. TEpollSocketÀÌ ¾Ë¾Æ¼ ó¸®ÇÒ °ÍÀÌ´Ù ;)
return nerror;
};