Starting work on blocking tranport.
This commit is contained in:
@@ -31,6 +31,9 @@ SRC_DIRS += $(PVACCESS)/factory
|
||||
LIBSRCS += ChannelAccessFactory.cpp
|
||||
|
||||
|
||||
SRC_DIRS += $(PVACCESS)/remote
|
||||
INC += blockingUDPTransport.h
|
||||
LIBSRCS += blockingUDPTransport.cpp
|
||||
|
||||
|
||||
LIBRARY = pvAccess
|
||||
|
||||
70
pvAccessApp/remote/blockingUDPTransport.cpp
Normal file
70
pvAccessApp/remote/blockingUDPTransport.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* blockingUDPTransport.cpp
|
||||
*
|
||||
* Created on: Dec 20, 2010
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
/* pvAccess */
|
||||
#include "blockingUDPTransport.h"
|
||||
|
||||
#include "caConstants.h"
|
||||
|
||||
/* pvData */
|
||||
#include <byteBuffer.h>
|
||||
|
||||
/* EPICSv3 */
|
||||
#include <osdSock.h>
|
||||
#include <osiSock.h>
|
||||
#include <errlog.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
85
pvAccessApp/remote/blockingUDPTransport.h
Normal file
85
pvAccessApp/remote/blockingUDPTransport.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* blockingUDPTransport.h
|
||||
*
|
||||
* Created on: Dec 20, 2010
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#ifndef BLOCKINGUDPTRANSPORT_H_
|
||||
#define BLOCKINGUDPTRANSPORT_H_
|
||||
|
||||
#include <noDefaultMethods.h>
|
||||
#include <byteBuffer.h>
|
||||
|
||||
#include <osdSock.h>
|
||||
#include <osiSock.h>
|
||||
|
||||
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_ */
|
||||
Reference in New Issue
Block a user