c++ - Custom Socket Inheriting from boost::asio::ip::tcp::socket -
I am quite new in the C ++ legacy, and I am using promotion sockets. I want to make something comparable to Java's data-output stream for a synchronous boost socket. That is, I am trying to do methods like SendInt, ReadLong, etc. I tried to create a class that inherited from socket, but I continue to have errors, now I have something like this:
DataSocketStream.h
# Include "boost / asio.hpp" #include & lt; Vector & gt; Namespace Server {namespace std; As the namespace = boost :: asio; Nameshot IP = Promotion :: ASIO :: IP; Class Datasetset Stream: Public IP :: TCP :: Socket {Public: Datasocket Stream (eg: io_service); Virtual ~ dataset stream (); Zero WriteInt (int); Zero (long) written; Int ReadInt (boost :: system :: error_code); Read longer (boost :: system :: error_code); Zero flush (boost :: system :: errorGod); String Reedstring (boost :: system :: errorGod); Double ReadDouble (boost :: system :: error_code); Zero WriteDouble (double); Private: ip :: tcp :: socket * socketFormPtr std :: vector & lt; Char & gt; message; }; DataSocketStream.cpp
#include "DataSocketStream.h" namespace server {namespace = boost :: asio; Nameshot IP = Promotion :: ASIO :: IP; using namespace std; DataSocketStream :: DataSocketStream (like: io_service ios): ip :: tcp :: socket (ios) {socketFormPtr = this; } DataSocketStream :: ~ DataSocketStream () {} Zero DataSocketStream :: WriteInt (int toWrite) {// implementation which pushes the bytes on vector message} Zero DataSocketStream :: WriteLong {long write} {//. .} Zero DataSocketStream :: Flush (Promotion :: System :: ErrorGode E) {as: :: Write (* SocketFormPrint, :: Buffer (Message), as :: Transfirm (), e); Delete (& Message); Std :: vector & lt; Four & gt; message; } Int DataSocketStream :: ReadInt (boost :: system :: error_code e) {char f [4]; As :: Read (* socketFormPtr, as: Buffer (AF), E); Return ((F [0] However, when I try I am doing something like: io_service io_service; DataSocketStream CLsocket (io_service);
The compiler gives me an error, error: 'boost :: noncopyable _ :: noncopyable :: noncopyable (const boost :: noncopyable _ :: noncopyable) is private I figured that to my class Boost is not part of the library with something to do.
I tried inheriting from other boost :: asio :: basic_stream_socket, but I also got errors in doing so. (This was a very strange "illegal use" :: "error ') I tried to create a general boost :: asio :: ip :: tcp :: socket and then casting point to pointer at the pointer of datasocketstream It was, but it
I know that I can do all these helpful methods such as:
int ReadInt (boost :: asio :: ip :: Tcp :: socket * S, boost :: system :: error_code e) {ARH [4]; As :: Read (* S, as: Buffer (AF), E); Return ((F [0] <24) | (F [1] But the path of inheritance seems to be a better design. Do I remember something, or do I think the way I am trying to The extended library is not really extended? Thanks!
one
< Code> DataSocketStream (as: io_service); An io_service is noncopyable as an error, pass it to the reference
DataSocketStream (eg: io_service & Amp;;); ^
Comments
Post a Comment