Core: Socket::GetLine fixed reaction to EOF

git-svn-id: svn://ultimatepp.org/upp/trunk@7104 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-03-27 10:32:25 +00:00
commit d2af891121
5 changed files with 18 additions and 9 deletions

View file

@ -15,7 +15,7 @@ NAMESPACE_UPP
#pragma comment(lib, "ws2_32.lib")
#endif
#define LLOG(x) // DLOG("TCP " << x)
#define LLOG(x) // LOG("TCP " << x)
IpAddrInfo::Entry IpAddrInfo::pool[COUNT];
@ -741,6 +741,11 @@ void TcpSocket::ReadBuffer(int end_time)
end = buffer + Recv(buffer, BUFFERSIZE);
}
bool TcpSocket::IsEof() const
{
return is_eof && ptr == end || IsAbort() || !IsOpen() || IsError();
}
int TcpSocket::Get_()
{
if(!IsOpen() || IsError() || IsEof() || IsAbort())
@ -829,10 +834,12 @@ String TcpSocket::GetAll(int len)
String TcpSocket::GetLine(int maxlen)
{
LLOG("GetLine " << maxlen);
LLOG("GetLine " << maxlen << ", iseof " << IsEof());
String ln;
int end_time = GetEndTime();
for(;;) {
if(IsEof())
return String::GetVoid();
int c = Peek(end_time);
if(c < 0) {
if(!IsError())