1
0

Can now receive POST data in WebPlugins!

Fixed Debug With optimized Noise in VS2010 by having it run the correct MCServer_debug.exe instead of MCServer.exe
Changed winsock.h to Winsock2.h in Globals.h so sockets can be graciously closed (See webserver Socket::Close() )

git-svn-id: http://mc-server.googlecode.com/svn/trunk@197 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth
2012-01-31 00:38:18 +00:00
parent f4583fda98
commit c142424571
14 changed files with 224 additions and 117 deletions

View File

@@ -118,11 +118,20 @@ Socket& Socket::operator=(Socket& o) {
return *this;
}
void Socket::Close() {
void Socket::Close( bool a_WaitSend /* = false */ )
{
if( s_ )
{
closesocket(s_);
s_ = 0;
if( a_WaitSend )
{
assert( shutdown(s_, SD_SEND ) == 0 );
char c;
while( recv(s_, &c, 1, 0 ) != 0 )
{}
}
closesocket(s_);
s_ = 0;
}
}
@@ -135,12 +144,25 @@ std::string Socket::ReceiveLine() {
{
return "";
}
ret += r;
if (r == '\n') return ret;
}
}
std::string Socket::ReceiveBytes( unsigned int a_Length ) {
std::string ret;
while( ret.size() < a_Length ) {
char r;
if (recv(s_, &r, 1, 0) <= 0 )
{
return "";
}
ret += r;
}
return ret;
}
void Socket::SendLine(std::string s) {
s += '\n';
if( send(s_,s.c_str(),s.length(),MSG_NOSIGNAL) <= 0 )