transport: (temporary) remove UDP and TCP transports
This is preparation for fully async transport implementations
Change-Id: Ib5a08bcbdfdbd5f4e7cada782ba58ecc8d2b1085
diff --git a/include/ndn-cpp/transport/tcp-transport.hpp b/include/ndn-cpp/transport/tcp-transport.hpp
deleted file mode 100644
index e54516a..0000000
--- a/include/ndn-cpp/transport/tcp-transport.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NDN_TCPTRANSPORT_HPP
-#define NDN_TCPTRANSPORT_HPP
-
-#include <string>
-#include "../common.hpp"
-#include "transport.hpp"
-
-struct ndn_TcpTransport;
-struct ndn_BinaryXmlElementReader;
-
-namespace ndn {
-
-class TcpTransport : public Transport {
-public:
- TcpTransport(const char *host, unsigned short port = 6363);
-
- /**
- * Connect according to the info in ConnectionInfo, and processEvents() will use elementListener.
- * @param connectionInfo A reference to a TcpTransport::ConnectionInfo.
- * @param elementListener Not a shared_ptr because we assume that it will remain valid during the life of this object.
- */
- virtual void connect(ElementListener& elementListener);
-
- /**
- * Set data to the host
- * @param data A pointer to the buffer of data to send.
- * @param dataLength The number of bytes in data.
- */
- virtual void send(const uint8_t *data, size_t dataLength);
-
- /**
- * Process any data to receive. For each element received, call elementListener.onReceivedElement.
- * This is non-blocking and will return immediately if there is no data to receive.
- * You should normally not call this directly since it is called by Face.processEvents.
- * @throw This may throw an exception for reading data or in the callback for processing the data. If you
- * call this from an main event loop, you may want to catch and log/disregard all exceptions.
- */
- virtual void processEvents();
-
- virtual bool getIsConnected();
-
- /**
- * Close the connection to the host.
- */
- virtual void close();
-
- ~TcpTransport();
-
-private:
- std::string host_;
- unsigned short port_;
-
- bool isConnected_;
- ptr_lib::shared_ptr<struct ndn_TcpTransport> transport_;
- // TODO: This belongs in the socket listener.
- ptr_lib::shared_ptr<struct ndn_BinaryXmlElementReader> elementReader_;
-};
-
-}
-
-#endif
diff --git a/include/ndn-cpp/transport/udp-transport.hpp b/include/ndn-cpp/transport/udp-transport.hpp
deleted file mode 100644
index 39dfbe2..0000000
--- a/include/ndn-cpp/transport/udp-transport.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#ifndef NDN_UDPTRANSPORT_HPP
-#define NDN_UDPTRANSPORT_HPP
-
-#include <string>
-#include "../common.hpp"
-#include "transport.hpp"
-
-struct ndn_UdpTransport;
-struct ndn_BinaryXmlElementReader;
-
-namespace ndn {
-
-class UdpTransport : public Transport {
-public:
- /**
- * Create a UdpTransport with the given host and port.
- * @param host The host for the connection.
- * @param port The port number for the connection. If omitted, use 6363.
- */
- UdpTransport(const char *host, unsigned short port = 6363);
-
- /**
- * Connect according to the info in ConnectionInfo, and processEvents() will use elementListener.
- * @param connectionInfo A reference to a TcpTransport::ConnectionInfo.
- * @param elementListener Not a shared_ptr because we assume that it will remain valid during the life of this object.
- */
- virtual void
- connect(ElementListener& elementListener);
-
- /**
- * Set data to the host
- * @param data A pointer to the buffer of data to send.
- * @param dataLength The number of bytes in data.
- */
- virtual void
- send(const uint8_t *data, size_t dataLength);
-
- /**
- * Process any data to receive. For each element received, call elementListener.onReceivedElement.
- * This is non-blocking and will return immediately if there is no data to receive.
- * You should normally not call this directly since it is called by Face.processEvents.
- * @throw This may throw an exception for reading data or in the callback for processing the data. If you
- * call this from an main event loop, you may want to catch and log/disregard all exceptions.
- */
- virtual void
- processEvents();
-
- virtual bool
- getIsConnected();
-
- /**
- * Close the connection to the host.
- */
- virtual void
- close();
-
- ~UdpTransport();
-
-private:
- std::string host_;
- unsigned short port_;
-
- bool isConnected_;
- ptr_lib::shared_ptr<struct ndn_UdpTransport> transport_;
- // TODO: This belongs in the socket listener.
- ptr_lib::shared_ptr<struct ndn_BinaryXmlElementReader> elementReader_;
-};
-
-}
-
-#endif
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
deleted file mode 100644
index cb1c6e3..0000000
--- a/src/transport/tcp-transport.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#include <stdexcept>
-#include <stdlib.h>
-#include <ndn-cpp/node.hpp>
-#include "../c/transport/tcp-transport.h"
-#include "../c/encoding/binary-xml-element-reader.h"
-#include "../c/util/ndn_realloc.h"
-#include <ndn-cpp/transport/tcp-transport.hpp>
-
-using namespace std;
-
-namespace ndn {
-
-TcpTransport::TcpTransport(const char *host, unsigned short port/* = 6363*/)
- : host_(host), port_(port)
- , isConnected_(false), transport_(new struct ndn_TcpTransport), elementReader_(new struct ndn_BinaryXmlElementReader)
-{
- ndn_TcpTransport_initialize(transport_.get());
- elementReader_->partialData.array = 0;
-}
-
-void
-TcpTransport::connect(ElementListener& elementListener)
-{
- ndn_Error error;
- if ((error = ndn_TcpTransport_connect(transport_.get(), (char *)host_.c_str(), port_)))
- throw runtime_error(ndn_getErrorString(error));
-
- // TODO: This belongs in the socket listener.
- const size_t initialLength = 1000;
- // Automatically cast elementReader_ to (struct ndn_ElementListener *)
- ndn_BinaryXmlElementReader_initialize
- (elementReader_.get(), &elementListener, (uint8_t *)malloc(initialLength), initialLength, ndn_realloc);
-
- isConnected_ = true;
-}
-
-void
-TcpTransport::send(const uint8_t *data, size_t dataLength)
-{
- ndn_Error error;
- if ((error = ndn_TcpTransport_send(transport_.get(), (uint8_t *)data, dataLength)))
- throw runtime_error(ndn_getErrorString(error));
-}
-
-void
-TcpTransport::processEvents()
-{
- int receiveIsReady;
- ndn_Error error;
- if ((error = ndn_TcpTransport_receiveIsReady(transport_.get(), &receiveIsReady)))
- throw runtime_error(ndn_getErrorString(error));
- if (!receiveIsReady)
- return;
-
- uint8_t buffer[8000];
- size_t nBytes;
- if ((error = ndn_TcpTransport_receive(transport_.get(), buffer, sizeof(buffer), &nBytes)))
- throw runtime_error(ndn_getErrorString(error));
-
- ndn_BinaryXmlElementReader_onReceivedData(elementReader_.get(), buffer, nBytes);
-}
-
-bool
-TcpTransport::getIsConnected()
-{
- return isConnected_;
-}
-
-void
-TcpTransport::close()
-{
- ndn_Error error;
- if ((error = ndn_TcpTransport_close(transport_.get())))
- throw runtime_error(ndn_getErrorString(error));
-}
-
-TcpTransport::~TcpTransport()
-{
- if (elementReader_->partialData.array)
- // Free the memory allocated in connect.
- free(elementReader_->partialData.array);
-}
-
-}
diff --git a/src/transport/udp-transport.cpp b/src/transport/udp-transport.cpp
deleted file mode 100644
index aaf3d06..0000000
--- a/src/transport/udp-transport.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#include <stdexcept>
-#include <stdlib.h>
-#include <ndn-cpp/face.hpp>
-#include "../c/transport/udp-transport.h"
-#include "../c/encoding/binary-xml-element-reader.h"
-#include "../c/util/ndn_realloc.h"
-#include <ndn-cpp/transport/udp-transport.hpp>
-
-using namespace std;
-
-namespace ndn {
-
-UdpTransport::UdpTransport(const char *host, unsigned short port/* = 6363*/)
- : host_(host), port_(port)
- , isConnected_(false), transport_(new struct ndn_UdpTransport), elementReader_(new struct ndn_BinaryXmlElementReader)
-{
- ndn_UdpTransport_initialize(transport_.get());
- elementReader_->partialData.array = 0;
-}
-
-void
-UdpTransport::connect(ElementListener& elementListener)
-{
- ndn_Error error;
- if ((error = ndn_UdpTransport_connect(transport_.get(), (char *)host_.c_str(), port_)))
- throw runtime_error(ndn_getErrorString(error));
-
- // TODO: This belongs in the socket listener.
- const size_t initialLength = 1000;
- // Automatically cast elementReader_ to (struct ndn_ElementListener *)
- ndn_BinaryXmlElementReader_initialize
- (elementReader_.get(), &elementListener, (uint8_t *)malloc(initialLength), initialLength, ndn_realloc);
-
- isConnected_ = true;
-}
-
-void
-UdpTransport::send(const uint8_t *data, size_t dataLength)
-{
- ndn_Error error;
- if ((error = ndn_UdpTransport_send(transport_.get(), (uint8_t *)data, dataLength)))
- throw runtime_error(ndn_getErrorString(error));
-}
-
-void
-UdpTransport::processEvents()
-{
- int receiveIsReady;
- ndn_Error error;
- if ((error = ndn_UdpTransport_receiveIsReady(transport_.get(), &receiveIsReady)))
- throw runtime_error(ndn_getErrorString(error));
- if (!receiveIsReady)
- return;
-
- uint8_t buffer[8000];
- size_t nBytes;
- if ((error = ndn_UdpTransport_receive(transport_.get(), buffer, sizeof(buffer), &nBytes)))
- throw runtime_error(ndn_getErrorString(error));
-
- ndn_BinaryXmlElementReader_onReceivedData(elementReader_.get(), buffer, nBytes);
-}
-
-bool
-UdpTransport::getIsConnected()
-{
- return isConnected_;
-}
-
-void
-UdpTransport::close()
-{
- ndn_Error error;
- if ((error = ndn_UdpTransport_close(transport_.get())))
- throw runtime_error(ndn_getErrorString(error));
-}
-
-UdpTransport::~UdpTransport()
-{
- if (elementReader_->partialData.array)
- // Free the memory allocated in connect.
- free(elementReader_->partialData.array);
-}
-
-}