📄 fdconnection.cpp
字号:
/* * This program 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; either version 2 of the License, or * (at your option) any later version. * * This program 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 Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */// FdConnection.cpp - Copyright Simon Brenner 2002,2005#include <fcntl.h>#include "FdConnection.hpp"#include "async.h"FdConnection::~FdConnection(){ if (LastSocketObject(fd)) RemoveSocket(fd, this);}bool FdConnection::Connect(){ return true;}void FdConnection::Disconnect(){}bool FdConnection::Write(void *buf, uint len){ return !(write(fd, buf, len)<0);}bool FdConnection::Read(void *buf, uint len, uint *bytesRead){ int ret=read(fd, buf, len); if (bytesRead != NULL) *bytesRead=ret; return !(ret < 0);}bool FdConnection::setNonBlocking(bool non_block){ int oldflags=fcntl(fd, F_GETFL, 0); if (oldflags == -1) return true; if (non_block) oldflags |= O_NONBLOCK; else oldflags &= ~O_NONBLOCK; return fcntl(fd, F_SETFL, oldflags);}void FdConnection::OnRead(){}void FdConnection::OnWrite(){}void FdConnection::OnClose(){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -