📄 sockunix.cpp
字号:
// sockunix.cpp -*- C++ -*- socket library// Copyright (C) 2002 Herbert Straub//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//// sockunix.C -*- C++ -*- socket library// Copyright (C) 1992-1996 Gnanasekaran Swaminathan <gs4t@virginia.edu>//// Permission is granted to use at your own risk and distribute this software// in source and binary forms provided the above copyright notice and this// paragraph are preserved on all copies. This software is provided "as is"// with no express or implied warranty.//// Version: 12Jan97 1.11// 2002-07-28 Version 1.2 (C) Herbert Straub// Eliminating sorry_about_global_temp inititialisation. This don't work// in combination with NewsCache. My idea is: initializing the classes with (0)// and in the second step call ios::init (sockinetbuf *) and iosockstream::init ...// The constructors of isockunix, osockunix and iosockunix are changed.using namespace std;#include <sockunix.h>#include <sys/socket.h>#include <string.h>sockunixaddr::sockunixaddr (const char* path){ sun_family = sockunixbuf::af_unix; ::strcpy (sun_path, path);}sockunixaddr::sockunixaddr (const sockunixaddr& suna){ sun_family = sockunixbuf::af_unix; ::strcpy (sun_path, suna.sun_path);}sockunixbuf::sockunixbuf (const sockbuf::sockdesc& sd) : sockbuf (sd.sock){}sockunixbuf::sockunixbuf (const sockunixbuf& su) : sockbuf (su){}sockunixbuf::sockunixbuf (sockbuf::type ty, int proto) : sockbuf (af_unix, ty, proto){}/*sockunixbuf& sockunixbuf::operator = (const sockunixbuf& su){ sockbuf::operator = (su); return *this;}*/void sockunixbuf::bind (sockAddr& sa){ sockbuf::bind (sa);}void sockunixbuf::bind (const char* path){ sockunixaddr sa (path); bind (sa);}void sockunixbuf::connect (sockAddr& sa){ sockbuf::connect (sa);}void sockunixbuf::connect (const char* path){ sockunixaddr sa (path); connect (sa);}isockunix::isockunix (const sockbuf::sockdesc& sd) : ios (0), isockstream(0){ sockunixbuf *t = new sockunixbuf (sd); ios::init (t); isockstream::init (t);}isockunix::isockunix (sockbuf::type ty, int proto) : ios (0), isockstream(0){ sockunixbuf *t = new sockunixbuf (ty, proto); ios::init (t); isockstream::init (t);}isockunix::isockunix (const sockunixbuf& sb) : ios (0), isockstream(0){ sockunixbuf *t = new sockunixbuf (sb); ios::init (t); isockstream::init (t);}isockunix::~isockunix (){ delete ios::rdbuf ();}osockunix::osockunix (const sockbuf::sockdesc& sd) : ios (0), osockstream(0){ sockunixbuf *t = new sockunixbuf (sd); ios::init (t); osockstream::init (t);}osockunix::osockunix (sockbuf::type ty, int proto) : ios (0), osockstream(0){ sockunixbuf *t = new sockunixbuf (ty, proto); ios::init (t); osockstream::init (t);}osockunix::osockunix (const sockunixbuf& sb) : ios (0), osockstream(0){ sockunixbuf *t= new sockunixbuf (sb); ios::init (t); osockstream::init (t);}osockunix::~osockunix (){ delete ios::rdbuf ();}iosockunix::iosockunix (const sockbuf::sockdesc& sd) : ios (0), iosockstream(0){ sockunixbuf *t = new sockunixbuf (sd); ios::init (t); iosockstream::init (t);}iosockunix::iosockunix (sockbuf::type ty, int proto) : ios (0), iosockstream(0){ sockunixbuf *t = new sockunixbuf (ty, proto); ios::init (t); iosockstream::init (t);}iosockunix::iosockunix (const sockunixbuf& sb) : ios (0), iosockstream(0){ sockunixbuf *t = new sockunixbuf (sb); ios::init (t); iosockstream::init (t);}iosockunix::~iosockunix (){ delete ios::rdbuf ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -