Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
292767eaa8 |
6
Makefile
6
Makefile
@ -7,9 +7,13 @@ TARGET=libi2psam.a
|
||||
$(TARGET): $(OBJS)
|
||||
$(AR) $(ARFLAGS) $(TARGET) $(OBJS)
|
||||
|
||||
LOADLIBES=-L./ -li2psam
|
||||
LOADLIBES=-L./ -li2psam -lboost_system -lboost_thread -lpthread
|
||||
|
||||
eepget: eepget.cpp $(TARGET)
|
||||
|
||||
export USE_BOOST=1
|
||||
|
||||
boost: boost.cpp $(TARGET)
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGET) $(OBJS) eepget
|
||||
|
17
i2psam.cpp
17
i2psam.cpp
@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
// Was 65536, seemed unnecessarily large
|
||||
#define SAM_BUFSIZE 4096
|
||||
@ -169,6 +170,22 @@ void I2pSocket::write(const std::string& msg)
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t I2pSocket::write_some(boost::asio::const_buffers_1 buffer, boost::system::error_code ec) {
|
||||
// get a string from the buffer
|
||||
std::string str(boost::asio::buffers_begin(buffer), boost::asio::buffers_end(buffer));
|
||||
// get the buffer size
|
||||
std::size_t size = boost::asio::buffer_size(buffer);
|
||||
write(str);
|
||||
return size;
|
||||
}
|
||||
|
||||
std::size_t I2pSocket::read_some(boost::asio::mutable_buffers_1 buffer, boost::system::error_code ec) {
|
||||
// get a string from the buffer
|
||||
//std::string str(boost::asio::buffers_begin(buffer), boost::asio::buffers_end(buffer));
|
||||
std::string str = read();
|
||||
return str.size();
|
||||
}
|
||||
|
||||
std::string I2pSocket::read()
|
||||
{
|
||||
if (!isOk())
|
||||
|
10
i2psam.h
10
i2psam.h
@ -45,12 +45,15 @@
|
||||
#ifdef __cplusplus // __cplusplus
|
||||
#include "compat.h"
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
using namespace boost::asio;
|
||||
|
||||
namespace SAM
|
||||
{
|
||||
|
||||
@ -213,6 +216,13 @@ public:
|
||||
|
||||
void write(const std::string& msg);
|
||||
std::string read();
|
||||
|
||||
// only include these if we're compiling with boost
|
||||
//#ifdef USE_BOOST
|
||||
std::size_t write_some(boost::asio::const_buffers_1 buffer, boost::system::error_code error);
|
||||
std::size_t read_some(boost::asio::mutable_buffers_1 buffer, boost::system::error_code error);
|
||||
//#endif
|
||||
|
||||
SOCKET release();
|
||||
void close();
|
||||
|
||||
|
Reference in New Issue
Block a user