c++ socket 客户端库 socks5 客户端 RudeSocket™ Open Source C++ Socket Library
介绍
一个c++ socket 客户端库
http://www.rudeserver.com/socket/index.html
The RudeSocket™ Open Source C++ Socket Library provides a simple to use interface for creating and using client sockets. You can connect to the destination server through an unlimited number of chainable proxies, SOCKS4 and SOCKS5 servers if anonymity or security is a priority. Supports SSL [1] as well as normal connections. Supports timeouts. Full version requires that openSSL libraries are installed. However, a lite version is available if SSL is not required or available.
The library is currently available for linux development environments.
Features:
- SSL Support (Linux and Windows) [1]
- Supports Sockes 4, Socks 5, HTTP Proxy
- Like all RudeServer Libraries: Simple and Easy to use.
- Open Source and Free
- Platform Independent Interface
[1] - This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
用法
General Usage
Socket *socket = new Socket();
socket->connect("google.com", 80);
socket->sends("GET / HTTP/1.0\n\n");
const char *response = socket->reads();
cout << response;
socket->close();
SSL Usage
Socket *socket = new Socket();
socket->connectSSL("google.com", 443);
socket->sends("GET / HTTP/1.0\n\n");
const char *response = socket->reads();
cout << response;
socket->close();
Chaining Connections
Socket *socket = new Socket();
socket->insertSocks4("12.34.56.78", 8000, "username");
socket->insertSocks5("12.34.56.78", 8000, "username", "password");
socket->insertProxy("12.34.56.78", 8080);
socket->connectSSL("google.com", 443);
socket->sends("GET / HTTP/1.0\n\n");
const char *response = socket->reads();
cout << response;
socket->close();
Adding Error checking
Socket *socket = new Socket();
if(socket->connectSSL("google.com", 443))
{
if(socket->sends("GET / HTTP/1.0\n\n"))
{
const char *response = socket->reads();
if(response)
{
cout << response;
}
else
{
cout << socket->getError() << "\n";
}
}
else
{
cout << socket->getError() << "\n";
}
socket->close();
}
else
{
cout << socket->getError() << "\n";
}
| Constructor Summary | |
Socket() Constructor |
|
~Socket() Destructor |
|
| Method Summary | |
bool |
close() Closes the connection |
bool |
connect( const char* server, int port ) Connects to the specified server and port |
bool |
connectSSL( const char* server, int port ) Connects to the specified server and port over a secure connection |
const char* |
getError() Returns a description of the last known error |
bool |
insertProxy( const char* server, int port ) Inserts a CONNECT-Enabled HTTP proxy into the connect chain |
bool |
insertSocks4( const char* server, int port, const char* username ) Inserts a Socks4 server into the connect chain |
bool |
insertSocks5( const char* server, int port, const char* username, const char* password ) Inserts a Socks5 server into the connect chain |
bool |
insertTunnel( const char* server, int port ) Inserts a transparent tunnel into the connect chain |
int |
read( char* buffer, int length ) Reads a buffer of data from the connection |
const char* |
readline() Reads a line from the connection |
const char* |
reads() Reads everything available from the connection |
int |
send( const char* data, int length ) Sends a buffer of data over the connection |
bool |
sends( const char* buffer ) Sends a null terminated string over the connection |
void |
setMessageStream( std::ostream& o ) Sets an output stream to receive realtime messages about the socket |
void |
setTimeout( int seconds, int microseconds ) Sets the timeout value for Connect, Read and Send operations. |
| Constructor Detail |
Socket
public Socket();
- Constructor
~Socket
public ~Socket();
- Destructor
| Method Detail |
close
public bool close();
- Closes the connection
A connection must established before this method can be called
connect
public bool connect( const char* server, int port );
- Connects to the specified server and port
If proxies have been specified, the connection passes through tem first.
connectSSL
public bool connectSSL( const char* server, int port );
- Connects to the specified server and port over a secure connection
If proxies have been specified, the connection passes through them first.
getError
public const char* getError();
- Returns a description of the last known error
insertProxy
public bool insertProxy( const char* server, int port );
- Inserts a CONNECT-Enabled HTTP proxy into the connect chain
Becomes the last server connected to in the chain before connecting to the destination server
insertSocks4
public bool insertSocks4( const char* server, int port, const char* username );
- Inserts a Socks4 server into the connect chain
Becomes the last server connected to in the chain before connecting to the destination server
insertSocks5
public bool insertSocks5( const char* server, int port, const char* username, const char* password );
- Inserts a Socks5 server into the connect chain
Becomes the last server connected to in the chain before connecting to the destination server
insertTunnel
public bool insertTunnel( const char* server, int port );
- Inserts a transparent tunnel into the connect chain
A transparent Tunnel is a server that accepts a connection on a certain port,
and always connects to a particular server:port address on the other side.
Becomes the last server connected to in the chain before connecting to the destination server
read
public int read( char* buffer, int length );
- Reads a buffer of data from the connection
A connection must established before this method can be called
readline
public const char* readline();
- Reads a line from the connection
A connection must established before this method can be called
reads
public const char* reads();
- Reads everything available from the connection
A connection must established before this method can be called
send
public int send( const char* data, int length );
- Sends a buffer of data over the connection
A connection must established before this method can be called
sends
public bool sends( const char* buffer );
- Sends a null terminated string over the connection
The string can contain its own newline characters.
Returns false and sets the error message if it fails to send the line.
A connection must established before this method can be called
setMessageStream
public void setMessageStream( std::ostream& o );
- Sets an output stream to receive realtime messages about the socket
setTimeout
public void setTimeout( int seconds, int microseconds );
- Sets the timeout value for Connect, Read and Send operations.
Setting the timeout to 0 removes the timeout - making the Socket blocking.
编译:
官方原版源码下载:点击下载
删除socket_platform.h文件包含 #include <winsock2.h> 的代码,以防止重写义的问题
c++ socket 客户端库 socks5 客户端 RudeSocket™ Open Source C++ Socket Library的更多相关文章
- Socket网络编程--FTP客户端
Socket网络编程--FTP客户端(1)(Windows) 已经好久没有写过博客进行分享了.具体原因,在以后说. 这几天在了解FTP协议,准备任务是写一个FTP客户端程序.直接上干货了. 0.了解F ...
- Socket网络编程--FTP客户端(1)(Windows)
已经好久没有写过博客进行分享了.具体原因,在以后说. 这几天在了解FTP协议,准备任务是写一个FTP客户端程序.直接上干货了. 0.了解FTP作用 就是一个提供一个文件的共享协议. 1.了解FTP协议 ...
- Socket网络编程--FTP客户端(60篇socket博客,而且都比较简单、深入浅出)
已经好久没有写过博客进行分享了.具体原因,在以后说. 这几天在了解FTP协议,准备任务是写一个FTP客户端程序.直接上干货了. 0.了解FTP作用 就是一个提供一个文件的共享协议. 1.了解FTP协议 ...
- Redis学习之路(008)- Redis C语言客户端库hiredis文档翻译
Hiredis是Redis数据库一个轻量的C语言客户端库. 之所以轻量是由于它只是简单的提供了对redis操作语句支持的接口,并没有实现具体的操作语句的功能.但正是由于这种设计使我们只要熟悉了通用的r ...
- c++下基于windows socket的单线程服务器客户端程序(基于TCP协议)
今天自己编写了一个简单的c++服务器客户端程序,注释较详细,在此做个笔记. windows下socket编程的主要流程可概括如下:初始化ws2_32.dll动态库-->创建套接字-->绑定 ...
- 计算机网络:套接字(Socket)| Python socket实现服务器端与客户端通信,使用TCP socket阿里云ECS服务器与本机通信
所谓套接字(Socket),就是对网络中不同主机上的应用进程之间进行双向通信的端点的抽象.一个套接字就是网络上进程通信的一端,提供了应用层进程利用网络协议交换数据的机制.从所处的地位来讲,套接字上联应 ...
- Alljoyn瘦客户端库介绍(官方文档翻译 下)
由于其他事情耽误,这个翻译现在才完成.接上篇—— 4 瘦客户端核心库架构 由于AllJoyn瘦客户端核心库(AJTCL)必须运行在那些功耗受限.计算能力有限.资源紧缺的设备上,因此它无法像运行在通用型 ...
- Alljoyn瘦客户端库介绍(官方文档翻译)
Alljoyn瘦客户端库介绍(上) 1.简介 本文档对AllJoynTM瘦客户端的核心库文件(AJTCL)进行了详尽的介绍.本文档介绍了系统整体架构,AllJoyn框架结构,并着重于介绍如何将嵌入式设 ...
- 尝试加载 Oracle 客户端库时引发 BadImageFormatException
尝试加载 Oracle 客户端库时引发 BadImageFormatException 工程师给计算机诊断,就像医生给病人诊断一样,很多同样的症状,可能是由多种截然不同的原因导致的. 最近进行C# ...
随机推荐
- 【RoR win32】提高rails new时bundle install运行速度
在新建rails项目时,rails new老是卡在bundle install那里,少则五分钟,多则几十分.这是因为rails new时自动会运行bundle install,而bundle inst ...
- 【py分析网页】可能有用的-re去除网页上的杂碎
def remove_js_css (content): """ remove the the javascript and the stylesheet and the ...
- django migrate10060 Duplicate column name错误
这个错误意思是有重复的列名,其实大部分原因是因为某些列被执行了多次,可以打开migration里面的django生成的文件去排查错误,然后自己手动修改数据库还原,实在不行可以把除了0001和init文 ...
- kvm虚拟机virt-manager启动报错
安装kvm,用virt-manager启动时报错如下: Traceback (most recent call last): File "/usr/share/virt-manager/v ...
- mysql引擎整理
MySQL数 据库引擎取决于MySQL在安装的时候是如何被编译的.要添加一个新的引擎,就必须重新编译MYSQL.在缺省情况下,MYSQL支持三个引 擎:ISAM.MYISAM和HEAP.另外两种类型I ...
- PHP使用PHPExcel删除Excel单元格指定列的方法是怎样
有一个系统仅公司内部和外部经销商使用,在一个导出功能中公司内部员工跟外部经销商导出的列是不一样的(某些数据是不能提供给经销商的)因为导出的数据都是一样的(某些列外数据外部没有)因此并没有单独处理,而是 ...
- 教你ECSHOP去版权与标志(新增272版)
前台部分: 1:去掉头部TITLE部分的ECSHOP演示站 Powered by ecshop 前者在后台商店设置 - 商店标题修改 后者打开includes/lib_main.php $page_t ...
- APP运营推广那点事【干货】
你的手机里面有多少应用?什么样的手机应用吸引你?下载之后经常用还是让他shi在那里?又或者刚点进去就卸载? 一款成功的应用,开发APP只是第一步,比前者更重要的是“养”APP,APP就像是一个需要不断 ...
- 加载 pcntl 多进程
加载 pcntl 有两种方式 一种重新编译安装,在编译时加 --enable-pcntl ./configure --prefix=/usr/local/php --with-mysql=/usr/l ...
- 如何在plSql查询数据查出的数据可编辑
最近开发项目时要经常自己造数据,遇到好多查询出数据时要进行修改.上网查询资料 总结如下: plSql允许查询数据可以编辑的条件是必须查询出rowid 在某个表上点击query data 出现的sql语 ...