]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - support/sdk/cpp/sf/tcpcomm.cpp
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / support / sdk / cpp / sf / tcpcomm.cpp
index 8e5efee52a1f6c2c08b60806ca3633bb33d56746..2e77a22cfca9efcf0b636fbe1f6856dcc5f7be9b 100644 (file)
@@ -38,6 +38,7 @@
 #include <iostream>
 #include <set>
 
+#include <cstring>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -210,17 +211,9 @@ int TCPComm::writeFD(int fd, const char *buffer, int count, int *err)
 /* writes packet */
 bool TCPComm::writePacket(int pFD, SFPacket &pPacket)
 {
-    char len = pPacket.getLength();
+    int len = pPacket.getTcpLength();
     int err;
-    if (writeFD(pFD, &len, 1, &err) != 1)
-    {
-        return false;
-    }
-    if (writeFD(pFD, pPacket.getPayload(), len, &err) != len)
-    {
-        return false;
-    }
-    return true;
+    return (writeFD(pFD, pPacket.getTcpPayload(), len, &err) == len);
 }
 
 /* checks for correct version of SF protocol */
@@ -590,7 +583,7 @@ void TCPComm::reportStatus(ostream& os)
 void TCPComm::stuffPipe() 
 {
     char info = 'n';
-    write(pipeWriteFD, &info, 1);
+    if(write(pipeWriteFD, &info, 1) != 1) DEBUG("TCPComm::stuffPipe : lokal pipe is broken");
 }
 
 void TCPComm::clearPipe() {