ncsid: Import from gBMC

This is the initial code drop from gBMC.

Google-Bug-Id: 179618516
Upstream: 1e71af914bc8c54d8b91d0a1cf377e2696713c2f
Change-Id: Ic653e8271dacd205e04f2bc713071ef2ec5936a4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ncsid/src/net_sockio.cpp b/ncsid/src/net_sockio.cpp
new file mode 100644
index 0000000..a4d7ec6
--- /dev/null
+++ b/ncsid/src/net_sockio.cpp
@@ -0,0 +1,36 @@
+#include "net_sockio.h"
+
+#include <sys/socket.h>
+#include <unistd.h>
+
+namespace net
+{
+
+int SockIO::close()
+{
+    int ret = 0;
+    if (sockfd_ >= 0)
+    {
+        ret = ::close(sockfd_);
+        sockfd_ = -1;
+    }
+
+    return ret;
+}
+
+int SockIO::write(const void* buf, size_t len)
+{
+    return ::write(sockfd_, buf, len);
+}
+
+int SockIO::recv(void* buf, size_t maxlen)
+{
+    return ::recv(sockfd_, buf, maxlen, 0);
+}
+
+SockIO::~SockIO()
+{
+    SockIO::close();
+}
+
+} // namespace net