From ea6b8b5c2c561024309e63587fdef89af4fecabd Mon Sep 17 00:00:00 2001 From: Myun2 Date: Mon, 14 May 2012 02:04:15 +0900 Subject: [PATCH] =?utf8?q?socket.hpp:=20socket=5Fbase=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/include/roast/io/io_base.hpp | 2 +- roast/include/roast/net/socket.hpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/roast/include/roast/io/io_base.hpp b/roast/include/roast/io/io_base.hpp index cbf7972e..3d7ff560 100644 --- a/roast/include/roast/io/io_base.hpp +++ b/roast/include/roast/io/io_base.hpp @@ -33,7 +33,7 @@ namespace roast public: //virtual ~io_base(){ _close(); } - //virtual bool connect()=0; + virtual bool connect(const void* options)=0; virtual bool close()=0; virtual int read(void *buf, size_t size)=0; diff --git a/roast/include/roast/net/socket.hpp b/roast/include/roast/net/socket.hpp index 6f81a759..63e55a07 100644 --- a/roast/include/roast/net/socket.hpp +++ b/roast/include/roast/net/socket.hpp @@ -13,8 +13,29 @@ namespace roast { + ///////////////////////////////////////////////////// + + class socket_base : public io_base + { + public: + virtual bool connect(const char* host, int port){} + virtual bool connect(const char* host, int port, int socktype, int family){} + + virtual int send(const void* s, size_t size, int flag=0)=0; + virtual int recv(void* s, size_t size, int flag=0)=0; + + public: + bool connect(const void* options){} + + int write(const void* buf, size_t size){ return send(buf, size); } + int read(void* buf, size_t size){ return recv(buf, size); } + int send(const char* s){ return send(s,strlen(s)); } + }; + + ///////////////////////////////////////////// + template - class basic_socket_ : public io_base + class basic_socket_// : public io_base { public: typedef _Impl Impl; -- 2.11.0