Fixed a typo and minor speedup in dtsc lib, fixed a bug when sending or receiving empty strings in socket lib.

This commit is contained in:
Thulinma 2012-11-13 23:20:17 +01:00
parent 2ad970f5df
commit 3ae5ac5be9
2 changed files with 4 additions and 4 deletions

View file

@ -145,7 +145,7 @@ std::string & DTSC::Stream::lastData(){
return *datapointer;
}
/// Returns the packed in this buffer number.
/// Returns the packet in this buffer number.
/// \arg num Buffer number.
JSON::Value & DTSC::Stream::getPacket(unsigned int num){
return buffers[num];
@ -169,7 +169,7 @@ bool DTSC::Stream::hasAudio(){
/// Returns a packed DTSC packet, ready to sent over the network.
std::string & DTSC::Stream::outPacket(unsigned int num){
static std::string emptystring;
if (num >= buffers.size()) return emptystring;
if (num >= buffers.size() || !buffers[num].isObject()) return emptystring;
return buffers[num].toNetPacked();
}

View file

@ -442,7 +442,7 @@ void Socket::Connection::Send(std::string & data){
/// \param len Amount of bytes to write.
/// \returns The amount of bytes actually written.
int Socket::Connection::iwrite(const void * buffer, int len){
if (!connected()){return 0;}
if (!connected() || len < 1){return 0;}
int r;
if (sock >= 0){
r = send(sock, buffer, len, 0);
@ -479,7 +479,7 @@ int Socket::Connection::iwrite(const void * buffer, int len){
/// \param len Amount of bytes to read.
/// \returns The amount of bytes actually read.
int Socket::Connection::iread(void * buffer, int len){
if (!connected()){return 0;}
if (!connected() || len < 1){return 0;}
int r;
if (sock >= 0){
r = recv(sock, buffer, len, 0);