diff --git a/pvAccessApp/Makefile b/pvAccessApp/Makefile index d322037..0c94ec2 100644 --- a/pvAccessApp/Makefile +++ b/pvAccessApp/Makefile @@ -31,6 +31,9 @@ SRC_DIRS += $(PVACCESS)/factory LIBSRCS += ChannelAccessFactory.cpp +SRC_DIRS += $(PVACCESS)/remote +INC += blockingUDPTransport.h +LIBSRCS += blockingUDPTransport.cpp LIBRARY = pvAccess diff --git a/pvAccessApp/remote/blockingUDPTransport.cpp b/pvAccessApp/remote/blockingUDPTransport.cpp new file mode 100644 index 0000000..2b98bd9 --- /dev/null +++ b/pvAccessApp/remote/blockingUDPTransport.cpp @@ -0,0 +1,70 @@ +/* + * blockingUDPTransport.cpp + * + * Created on: Dec 20, 2010 + * Author: Miha Vitorovic + */ + +/* pvAccess */ +#include "blockingUDPTransport.h" + +#include "caConstants.h" + +/* pvData */ +#include + +/* EPICSv3 */ +#include +#include +#include + +#include + + +namespace epics { + namespace pvAccess { + + using namespace epics::pvData; + + BlockingUDPTransport::BlockingUDPTransport(SOCKET channel, + osiSockAddr* bindAddress, osiSockAddr* sendAddresses, + short remoteTransportRevision) { + this->channel = channel; + this->bindAddress = bindAddress; + this->sendAddresses = sendAddresses; + + socketAddress = bindAddress; + + // allocate receive buffer + receiveBuffer = new ByteBuffer(MAX_UDP_RECV); + + // allocate send buffer and non-reentrant lock + sendBuffer = new ByteBuffer(MAX_UDP_SEND); + + ignoredAddresses = NULL; + closed = false; + lastMessageStartPosition = 0; + } + + BlockingUDPTransport::~BlockingUDPTransport() { + delete receiveBuffer; + delete sendBuffer; + } + + void BlockingUDPTransport::start() { + // TODO implement + } + + void BlockingUDPTransport::close(bool forced) { + if (closed) + return; + closed = true; + + if (bindAddress != NULL) + errlogSevPrintf( errlogInfo, "UDP connection to %d closed.", *bindAddress); + + //std::fclose(channel); + } + + } +} diff --git a/pvAccessApp/remote/blockingUDPTransport.h b/pvAccessApp/remote/blockingUDPTransport.h new file mode 100644 index 0000000..e52fc55 --- /dev/null +++ b/pvAccessApp/remote/blockingUDPTransport.h @@ -0,0 +1,85 @@ +/* + * blockingUDPTransport.h + * + * Created on: Dec 20, 2010 + * Author: Miha Vitorovic + */ + +#ifndef BLOCKINGUDPTRANSPORT_H_ +#define BLOCKINGUDPTRANSPORT_H_ + +#include +#include + +#include +#include + +namespace epics { + namespace pvAccess { + + class BlockingUDPTransport : public epics::pvData::NoDefaultMethods { + public: + BlockingUDPTransport(SOCKET channel, osiSockAddr* bindAddress, + osiSockAddr* sendAddresses, short remoteTransportRevision); + + ~BlockingUDPTransport(); + + bool isClosed() { + return closed; + } + + void start(); + void close(bool forced); + + protected: + bool closed; + + private: + // Context only used for logging in this class + + /** + * Corresponding channel. + */ + SOCKET channel; + + /** + * Cached socket address. + */ + osiSockAddr* socketAddress; + + /** + * Bind address. + */ + osiSockAddr* bindAddress; + + /** + * Send addresses. + */ + osiSockAddr* sendAddresses; + + /** + * Ignore addresses. + */ + osiSockAddr* ignoredAddresses; + + /** + * Receive buffer. + */ + epics::pvData::ByteBuffer* receiveBuffer; + + /** + * Send buffer. + */ + epics::pvData::ByteBuffer* sendBuffer; + + /** + * Last message start position. + */ + int lastMessageStartPosition; + + }; + + } +} + +#endif /* BLOCKINGUDPTRANSPORT_H_ */