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# ...
随机推荐
- 几款python集成开发环境
以下软件的测试环境为ArchLinux64位系统.对软件的介绍很粗略,详细介绍参考官网. 1-名称:eric 官网:http://eric-ide.python-projects.org/ 特点:该软 ...
- 开启xp_cmdshell
--打开xp_cmdshell EXEC sp_configure 'show advanced options', 1GORECONFIGUREGOEXEC sp_configure 'xp_cmd ...
- Server2003系统上的内置服务器设置某类IP无法访问问题
最近测试过程中遇到了一个很奇怪的现象,把服务器(测试产品)部署在Server2003系统的外网A上,把客户端(测试产品)部署在内网B,网络A,B用路由器相连,设置网络A为200.1.1.255,发现客 ...
- 160929、各数据库连接配置与maven依赖安装
最近做的项目都是maven的,据说maven是个东西.把依赖的jar文件的事情都委托出去辣!试着用了一下哈,效果还可以! 今天做了数据库配置这一块,特意把相关的东西总结出来,以备不时之需. MySQL ...
- jenkins+jmeter+ant搭建接口测试平台
接口测试的重点是检查数据的交换,传递和控制管理过程以及系统间的相互逻辑依赖关系. 接口测试的流程 项目启动后,测试人员要尽早拿到接口测试文档. 开始编写接口测试用例 将接口测试用例部署到持续集成的测试 ...
- 关于匿名类无法转换为object
缘由,不能在Razor中使用匿名类, 先事先封装了一个方法,用于Razor给cshtml模板返回页面. 在ashx一般处理程序中,是这样调用的 匿名类的格式如下:(只看格式,不看具体内容) 调用这样 ...
- Alarm(硬件时钟) init
http://blog.csdn.net/angle_birds/article/details/17302297 Alarm就是一个硬件时钟,前面我们已经知道它提供了一个定时器,用于把设备从睡眠状态 ...
- ZOJ 3860: - Find the Spy
3860 - Find the Spy Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu S ...
- HDU 4706:Children's Day
Children's Day Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- jqeury之轮播图
$(document).ready(function(){ var sWidth = $('#pic1').width(); var len = $('#pic1 .sildebar li').len ...