Logo
~Sockets~
~Examples~
~Contact~


Stdin.cpp

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2004  Anders Hedstrom
00008 Parts Copyright (c) Vergil of Ragestorm.net, 2003
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 #include <errno.h>
00025 #include "ISocketHandler.h"
00026 #include "Stdin.h"
00027 
00028 
00029 Stdin::Stdin(ISocketHandler& h,size_t bufsize) : Socket(h)
00030 ,m_bufsize(bufsize)
00031 {
00032         Attach( STDIN_FILENO );
00033         Set(true, false, false);
00034 }
00035 
00036 
00037 void Stdin::OnRead()
00038 {
00039         char buf[m_bufsize];
00040         int n = read(GetSocket(), buf, m_bufsize + 1); //recv(0, buf, 1000, 0);
00041         if (n == -1)
00042         {
00043                 Handler().LogError(this, "OnRead", errno, strerror(errno), LOG_LEVEL_FATAL);
00044                 SetCloseAndDelete();
00045                 return;
00046         }
00047         OnData(buf, n);
00048 }
00049 
00050 
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4