1 Star 0 Fork 24

phoenix85/socket

forked from eclipser/socket 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SocketInputStream.h 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
Administrator 提交于 2014-02-27 20:23 . 添加输入流
/*
* File: SocketInputStream.h
* Author: Vicky.H
* Email: eclipser@163.com
*
* Created on 2014年2月27日, 下午10:51
*/
#ifndef CN_VICKY__SOCKETINPUTSTREAM_H
#define CN_VICKY__SOCKETINPUTSTREAM_H
#include "Socket.h"
//初始化的接收缓存长度
#define DEFAULTSOCKETINPUTBUFFERSIZE 64 * 1024
//最大可以允许的缓存长度,如果超过此数值,则断开连接
#define DISCONNECTSOCKETINPUTSIZE 96 * 1024
class Packet;
// 输入流
class SocketInputStream {
public:
SocketInputStream(Socket* sock,
unsigned int BufferSize = DEFAULTSOCKETINPUTBUFFERSIZE,
unsigned int MaxBufferSize = DISCONNECTSOCKETINPUTSIZE);
virtual ~SocketInputStream();
public:
unsigned int Read(char* buf, unsigned int len);
bool ReadPacket(Packet* p);
bool Peek(char* buf, unsigned int len);
bool Find(char* buf);
bool Skip(unsigned int len);
unsigned int Fill();
unsigned int Fill_RAW();
void Initsize();
bool Resize(int size);
unsigned int Capacity()const {
return m_BufferLen;
}
unsigned int Length()const;
unsigned int Size()const {
return Length();
}
bool IsEmpty()const {
return m_Head == m_Tail;
}
void CleanUp();
unsigned int GetHead() {
return m_Head;
}
unsigned int GetTail() {
return m_Tail;
}
unsigned int GetBuffLen() {
return m_BufferLen;
}
char* GetBuff() {
return m_Buffer;
}
private:
Socket* m_pSocket;
char* m_Buffer;
unsigned int m_BufferLen;
unsigned int m_MaxBufferLen;
unsigned int m_Head;
unsigned int m_Tail;
};
#endif /* CN_VICKY__SOCKETINPUTSTREAM_H */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mywebgame/socket.git
git@gitee.com:mywebgame/socket.git
mywebgame
socket
socket
master

搜索帮助