.torrent: A .torrent fille contains all the info you need to download the file you want. For example, a torrent file has info on the size, the filename, and how to connect to other people (tracker). Another important function of the .torrent file is that it has a “hash” (sort of a digital signature) of each part of the file to make sure you don’t download corrupt of fake data but “the real thing”.
Client: The BitTorrent client is the application you use to “load” the .torrent file so that you can connect to other people. There are a lot of different torrent clients available. The three most popular clients are Bitcomet, Azureus and uTorrent. If you’re new to
BitTorrent I would recommend uTorrent, It’s light and has a great settings wizard to help you on your way.
Indexer: Indexers are websites which list (index) .torrent files (myBitTorrent, Torrentz, Mininova etc.).
Leecher: A leecher is someone who is downloading (and uploading) a file. You are a leecher if you do not have a complete copy of the file you’re trying to get. Note that a leecher normally is someone who’s not uploading, that’s not true in the BitTorrent jargon.
Peer: A peer is the same as a leecher, but without the negative connotation.
Ratio: The data you uploaded divided by the data you downloaded. A ratio higher than 1.00 means that you upload more than you download, which is a good thing. Most private trackers keep track of your ratio and will ban or block you if you have a bad ratio. Try to get at least a 1.00 or higher ratio.
Scrape: Scraping means that your BitTorrent client is requesting info from the “tracker” about other people who are down- or uploading the file. This is important because you need to know who has pieces of the file you still need.
Seeder: A seeder is someone who has a complete version of the file you are downloading. If there are no seeders, you probably wont be able to get the file. So seeders are extremely important, make sure to “seed” the torrent once you finished downloading.
Tracker: The tracker is a server that has all the info about the people that are down- and uploading the file. The tracker itself does not have a copy of the file, it only tracks the up- and dowloaders and makes sure people are able to connect to each other. A tracker is not the same as a website that hosts torrents. Mininova for example is not a tracker, just a “torrent-site”.
Super-Seed: Some clients have the option to “super-seed”. Super seeding is different from seeding because it tries to send out pieces of the file that have not been sent before. So instead of sending the same piece to several peers, it tries to send a unique piece to everyone so that other peers can swap those pieces.
Swarm: The swarm are all seeds and peers that are connected together. So if your client shows 5 seeds and 10 peers then that’s your swarm.
Azureus has a plugin to visualize the swarm
Now let’s see if you learned something. If you can understand the next sentence you probably have.
DHT: DHT stands for “Distributed Hash Table”. DHT layers “decentralize” torrents what make them more stable and less reliant on the web based trackers. If a web based tracker goes down, the torrents stay alive because peers can act as “nodes” keeping the swarm intact.
原文地址:http://torrentfreak.com/bittorrent-jargon/
posted @
2014-02-18 12:31 似水之心 阅读(537) |
评论 (0) |
编辑 收藏
1,首先通过App Store安装Xcode;@import url(http://www.cppblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
2,再安装Xcode command line tools;
3,下载squid源码,解包;
4,到源码目录,mkdir build, cd build;
5,sudo LIBS=-lresolv ../configure --prefix=/usr/squid
6,sudo make
7,sudo make install
安装完成
posted @
2013-12-20 13:16 似水之心 阅读(1278) |
评论 (0) |
编辑 收藏
posted @
2013-09-09 08:54 似水之心 阅读(384) |
评论 (0) |
编辑 收藏
针对现象
1, 运行程序提示“由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题”
2, 程序启动即发生异常,或者没反应。(具体现象跟系统设置有关)
3, 客户端发布必须连带msvcr80.dll,mfc80.dll等dll和manifest文件才能正常运行
问题定位
出现上述现象之后可以确定是缺少程序运行所需的环境,可以通过安装相应的vcredist_x86.exe来验证。针对vs版本,分别有
32位的(X86),也有64位的(X64),请注意区别下载。
★Microsoft Visual C++ 2005 Redistributable Package下载地址:
(x86):http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=zh-cn
(x64):http://www.microsoft.com/downloads/details.aspx?familyid=90548130-4468-4BBC-9673-D6ACABD5D13B&displaylang=zh-cn
★Microsoft Visual C++ 2008 Redistributable Package的下载地址:
(x86):http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5582
★Microsoft Visual C++ 2010 Redistributable Package
(x86):http://www.microsoft.com/download/en/details.aspx?id=5555?
(x64):http://www.microsoft.com/download/en/details.aspx?id=14632?
如果安装完之后可以正常运行程序,可以继续往下看,如果还不行,请考虑其它原因。
解决办法
如果可以接受,让用户自行下载VC运行库也是一种办法。
其次,可以把程序所需的dll一并发布。
如果不想带很多文件一起发布,可以使用静态链接发布程序。
静态链接MFC和ATL库的方法是:
Alt+F7打开Project Property,展开:
Configuration Properties
General
Use of MFC
Use of ATL
然后改成Static Library即可.如果已经是“在静态库中使用 MFC”了,生成之后在目标机器还是会有现象1的提示,那么很有可能就是没有静态链接C,C++运行库,
msvcr是C运行库,msvcp是C++运行库。如果你使用了STL之类C++的东西,msvcp就是必须的。修改方法如下:
静态链接MSVCR和MSVCP的办法是:
Alt+F7打开Project Property,展开:
Configuration Properties
C/C++
Code Generation
Runtime Library
然后将选项由/MD改为 "Multi-threaded (/MT)"
*再如果。。。。。按照上面操作完成之后程序依然有问题,请考虑:程序有没有静态连接其它的lib,而这些lib是不是也是同样静态连接的C,C++运行库,如果连接的lib还依赖和其它的lib,那么被依赖的lib是不是同样静态链接了C,C++运行库.*
举例说明
一个利用libtorrent库开发的下载测试程序(以下简称为例子)为win32项目,没有使用mfc,在纯净版系统上运行需要msvcr和msvcp的支持。例子编译依赖libtorrent.lib,而libtorrent.lib又深度依赖boost库,确保例子静态编译,不再依赖msvcr和msvcp的支持就必须在编译libtorrent.lib和boost库的时候明确静态链接c,c++运行库。经过实际测试,例子程序已经实现单独在纯净系统上的运行。
参考资料:
http://wylht.blogspot.com/2012_03_01_archive.html (需fan墙访问)
http://gamebabyrocksun.blog.163.com/blog/static/57153463201081101856593/
http://www.cnblogs.com/dementia/archive/2009/04/10/1433217.html
posted @
2013-09-09 08:48 似水之心 阅读(4418) |
评论 (0) |
编辑 收藏
1、安装手机驱动;
2、设置PC上的调制解调器属性;
A, 电脑右键,管理,设备管理,调制解调器;
B, 设置MODEM属性,高级-额外设置中,添加如下命令:
cmnet是:AT+CGDCONT=1,"ip","cmnet"
cmwap是:+CGDCONT=,,"cmwap"
3、cmnet拨号号码是:*99***1#
cmwap拨号号码是:*99#
用户名密码为空
数据线连接PC之后新建internet连接,按上面信息输入,拨号,正常的话成功之后就可以用PC打开网页了
posted @
2013-02-02 11:47 似水之心 阅读(1028) |
评论 (0) |
编辑 收藏
需要引用头文件:#include <afxinet.h>
CInternetSession sess ;
DWORD dwFlag = INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_DONT_CACHE|INTERNET_FLAG_RELOAD ;
CHttpFile *pF = (CHttpFile*)sess.OpenURL("http://www.google.cn/images/na666v_logo7.png",
1, dwFlag);
ASSERT(pF);
if(!pF)//网上有人说判断HttpFile指针是否为空就可以判断网络文件是否存在,经实验一直不为空,郁闷,是我的机器问题?
{
AfxThrowInternetException(1);
}
CString str;
pF->QueryInfo (HTTP_QUERY_STATUS_CODE, str);//HTTP_QUERY_STATUS_CODE查询状态信息,这里可以查询文件的大小等等,具体的在HTTP_QUERY_STATUS_CODE上右键,转到定义,有很多可选项
int b = _ttoi(str);
if (b==404)
{
AfxMessageBox("文件不存在");
}
else
{
AfxMessageBox("存在");
}
posted @
2009-10-20 16:09 似水之心 阅读(1524) |
评论 (0) |
编辑 收藏
首先是用ICMP检查网络是否连通:
bool Util::CheckInternet()
{
char *SendData = "Data Buffer";
LPVOID ReplyBuffer;
DWORD dwRetVal;
HANDLE hIcmpFile;
bool b=false;
if ((hIcmpFile = IcmpCreateFile()) == INVALID_HANDLE_VALUE)
return false;
ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
if ((dwRetVal = IcmpSendEcho(hIcmpFile,
inet_addr("209.131.36.158"), //用的雅虎的一个IP,可能延迟会大一点,用国内的会小一点
SendData, sizeof(SendData),
NULL, ReplyBuffer,
sizeof(ReplyBuffer) + sizeof(ICMP_ECHO_REPLY),
1000)) != 0) {
b=true;
}
free(ReplyBuffer);
return b;
}
很简单的几行代码,没有注释;
如果网络不通的话枚举拨号连接,进行拨号:
bool RASManager::ConnectNetwork()
{
RASENTRYNAME Entries[15];
DWORD cb,cEntries,dwRet;
Entries[0].dwSize=sizeof(RASENTRYNAME);
cb=sizeof(Entries);
cEntries=0;
dwRet=::RasEnumEntries(NULL, NULL, &Entries[0], &cb, &cEntries);//如果函数成功,则返回0
if(dwRet == 0)
{
CHAR szRasEntryName[RAS_MaxEntryName + 1]={0};
for(UINT i=0;i<cEntries;i++)
strcpy(szRasEntryName,Entries[i].szEntryName);
RASDIALPARAMS rdParams;
DWORD dwRet;
hConn=NULL;
rdParams.dwSize=sizeof(RASDIALPARAMS);
strcpy(rdParams.szEntryName,szRasEntryName);
strcpy(rdParams.szPhoneNumber,"#777");//我用的3G卡,拨#777号码
strcpy(rdParams.szUserName,"用户名");
strcpy(rdParams.szPassword,"密码");
strcpy(rdParams.szDomain,"");//这个也很重要,指定域,如果不指定这个的话下面注释的两句一定要加上,下边两句的意思是获取最后一次连接成功时的参数信息,如果用下边两句的话连同这行和这行上面的三行都可以省略
// BOOL fPass;
//RasGetEntryDialParams(NULL, &rdParams,&fPass);
dwRet=RasDial(NULL,NULL,&rdParams,0L,NULL,&hConn);
if(dwRet!=0)
{
return false;
}
return true;
}
else
{
return false;
}
}
预先建立拨号连接,以上拨号代码经过修改已经不需要保存密码,只建立一个拨号连接即可。
Windows XP or later: Do not use the
RasSetEntryDialParams
function. MSDN上面的说法就是
RasSetEntryDialParams
别在XP之后的系统上使用了。
检查拨号连接的状态,如果已经通过拨号连接上了网络当然不用再进行拨号了,代码如下:
bool RASManager::RasGetConnectStatus()
{
LPRASCONN lpRasConn = NULL;
DWORD cbBuf = 0;
DWORD cConn = 0;
DWORD dwRet = 0;
HRASCONN hrasconn;
bool bResult=FALSE;
RASCONNSTATUS rasStatus;
UINT ndx;
cbBuf = sizeof(RASCONN);
lpRasConn = (LPRASCONN)malloc((UINT)cbBuf);
if (lpRasConn != NULL)
{
lpRasConn->dwSize = sizeof(RASCONN);
dwRet = RasEnumConnections(lpRasConn,&cbBuf,&cConn);
for(ndx=0;ndx<cConn;ndx++)
{
hrasconn = lpRasConn[ndx].hrasconn;
rasStatus.dwSize = sizeof(RASCONNSTATUS);
dwRet = ::RasGetConnectStatus(hrasconn,&rasStatus);
if(dwRet)
bResult=FALSE;
else
{
if(rasStatus.rasconnstate == RASCS_Connected)
bResult=TRUE;
else
bResult=FALSE;
}
}
}
else
bResult=FALSE;
free(lpRasConn);
return bResult;
}
以上判断是如果检查到有一个已经连接的拨号连接就返回了,应该不会有两个或者以上的拨号连接同时连接,打开端口会失败的。
还有一个是断线:
void RASManager::HungUP()
{
LPRASCONN lpRasConn=NULL;
DWORD cbBuf = 0;
DWORD cConn = 0;
DWORD dwRet = 0;
HRASCONN hrasconn;
RASCONNSTATUS rasStatus;
UINT ndx;
cbBuf = sizeof(RASCONN);
lpRasConn = (LPRASCONN)malloc((UINT)cbBuf);
if(lpRasConn != NULL)
{
lpRasConn->dwSize = sizeof(RASCONN);
dwRet = RasEnumConnections(lpRasConn,&cbBuf,&cConn);
for(ndx=0;ndx<cConn;ndx++)
{
hrasconn = lpRasConn[ndx].hrasconn;
rasStatus.dwSize = sizeof(RASCONNSTATUS);
dwRet = ::RasGetConnectStatus(hrasconn,&rasStatus);
if(!dwRet)
{
if(rasStatus.rasconnstate == RASCS_Connected)
RasHangUp(hrasconn);
}
}
free(lpRasConn);
}
}
这个没什么好说的,执行关闭拨号连接的操作。
用程序创建连接,经过修改,已经可以正常创建连接,代码如下:
bool RASManager::CreateRASLink()
{
LPRASENTRY lpRasEntry = NULL;
DWORD cb = sizeof(RASENTRY);
DWORD dwBufferSize = 0;
DWORD dwRet = 0;
// 取得entry的大小,这句也不知道是不是必须的,因为sizeof(RASENTRY)和这里取到的dwBufferSize是一样的,不过还是Get一下安全点
RasGetEntryProperties(NULL,"", NULL, &dwBufferSize, NULL, NULL);
if (dwBufferSize == 0)
return false;
lpRasEntry = (LPRASENTRY)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBufferSize);
if (lpRasEntry == NULL)
return false;
ZeroMemory(lpRasEntry, sizeof(RASENTRY));
lpRasEntry->dwSize = dwBufferSize;
lpRasEntry->dwfOptions = RASEO_RemoteDefaultGateway|RASEO_PreviewPhoneNumber|RASEO_PreviewUserPw; // 这里的几个选项挺重要的,RASEO_RemoteDefaultGateway这个选项把创建的连接设置为默认连接,RASEO_PreviewPhoneNumber对应选项中的提示输入电话号码,RASEO_PreviewUserPw对应选项中的提示用户名和密码
lpRasEntry->dwType = RASET_Phone;
lstrcpy(lpRasEntry->szDeviceType, RASDT_Modem);
lstrcpy(lpRasEntry->szDeviceName,"www");
lpRasEntry->dwfNetProtocols = RASNP_Ip;
lpRasEntry->dwFramingProtocol = RASFP_Ppp;
dwRet = RasSetEntryProperties(NULL, "www", lpRasEntry, dwBufferSize, NULL, 0); // 创建连接
//The RasSetEntryProperties function changes the connection information for
an entry in the phone book or creates a new phone-book entry.(reference MSDN)
HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasEntry);
if (dwRet != 0)
return false;
return true;
}
上面的代码到是可以创建一个拨号连接,不过是个空的,里面没用用户名和密码等信息,需要用上面的拨号代码来指定拨号参数,不能使用
RasGetEntryDialParams来获取了。上面的代码基本上是在网络上搜索所得,稍加修改,在这里整理一下。
再补充一下删除连接的操作,代码如下:
void RASManager::DeletePhoneBookEntry()
{
RASENTRYNAME Entries[15];
DWORD cb,cEntries,dwRet;
Entries[0].dwSize=sizeof(RASENTRYNAME);
cb=sizeof(Entries);
cEntries=0;
dwRet=::RasEnumEntries(NULL, NULL, &Entries[0], &cb, &cEntries);//如果函数成功,则返回0
if(dwRet == 0)
{
CHAR szRasEntryName[RAS_MaxEntryName + 1]={0};
for(UINT i=0;i<cEntries;i++)
{
strcpy(szRasEntryName,Entries[i].szEntryName);
RasDeleteEntry(NULL,szRasEntryName);
}
}
}
要想实现自动启动拨号网络,就要使用Remote Access Service (RAS) API,这个API最早是在Windows for Workgroup 3.11中出现的,现在它已经成为Win32 API的一个组成部分。该API将整个拨号网络称为Phonebook,而每一个连接称为PhonebookEntry。你可以使用RasCreatePhonebookEntry来创建新的连接,用RasDial来拨号,而RasEnumEntries可以获得当前系统已有的所有连接,使用其它的RAS函数还可以获取或设置连接的参数。 RasEditPhonebookEntry函数将激活标准的Windows 95/NT属性对话框来修改连接的属性。你可以从Win32 API的手册找到所有相关函数的详细介绍。
补充:在windows中一个拨号连接即为一个PhonrbookEntry以下称为电话薄记录或是连接。总的这些称为Phonebook。
posted @
2009-10-10 17:27 似水之心 阅读(1571) |
评论 (0) |
编辑 收藏
int main()
{
int a[5]={1,2,3,4,5};
int *ptr1=(int *)(&a+1);
// a本身就为一个数组的地址,其值=&a[0],即数组第一个元素的地址,对a再取址
// &a = a,似乎没什么不同,其实这里发生了对齐变更,a+1的对齐是以int为界的
// 而&a+1是以整个数组为单位的,即5个int=20字节,这是关键!!!
// 那么&a+1实际是跨越了整个数组,可得ptr1存储了数组a最后一个元素5紧跟着的一个int的地址
int *ptr2=(int *)((int )a+1);
// 同理,(int)a先将其值(地址)转为整型值,再加一成为一个新的整数
// (int *)将这个值转换为一个指向int型变量的指针(地址)
// ptr2即存储了这个地址和指向的变量的类型
printf("%x,%x",ptr1[-1],*ptr2);
// 先解释一下a[-1],即将数组向前偏差一个类型大小的距离
// 数组a的内存布局(16进制):01000000 02000000 03000000 04000000 05000000
// ptr1[-1]
// 你说这里等于什么呢?数组a最后一个元素(5)紧跟着一个int的前面一个元素当然就是5了。
// *ptr2
// ptr2的值为a保存的地址值的绝对值+1,假设a=1000,那么(int)a+1=1001。
// 而后将其再转为(int *)指针,那么指针指向的内存布局为000000 02,即向后移了一个字节
// 那么在little-enddian架构下显示出来为02000000,低位在高地址。
return 0;
}
posted @
2009-09-24 11:14 似水之心 阅读(399) |
评论 (0) |
编辑 收藏
HANDLE PrnHandle;
if (OpenPrinter("EPSON Stylus Photo R270 Series",&PrnHandle,NULL))
{
unsigned char buf[8192];
DWORD dwSize;
if (GetPrinter(PrnHandle,2,buf,sizeof(buf),
&dwSize)) {
PRINTER_INFO_2* pInfo;
pInfo = (PRINTER_INFO_2*)buf;
//pInfo->Status 就是打印机的状态,详细的代码可以
//参见winspool.h中以PRINTER_STATUS开头的宏定义
if(pInfo->Status==PRINTER_STATUS_PAUSED)
AfxMessageBox("a");
else if(pInfo->Status==PRINTER_STATUS_PENDING_DELETION)
AfxMessageBox("b");
///////////以上pInfo->Status代码试验不成功,哪位知道原因请告知,谢谢
if (pInfo->Attributes&PRINTER_ATTRIBUTE_WORK_OFFLINE)//测试成功
{
AfxMessageBox("offline");
}
else
{
AfxMessageBox("online");
}
}
ClosePrinter(PrnHandle);
}
上面是判断打印机是否连机的。
下面是判断打印任务是否正常完成的:
SetTimer(1,500,NULL);//用定时器来完成
响应函数:
switch(nIDEvent)
{
case 1:
{
JOB_INFO_2 *pJobs;
int cJobs,
i;
DWORD dwPrinterStatus;
if (!GetJobs(hPrinter, &pJobs, &cJobs, &dwPrinterStatus))
return ;
for (i=0; i < cJobs; i++)
{
if (pJobs[i].Status &
(JOB_STATUS_ERROR |
JOB_STATUS_OFFLINE |
JOB_STATUS_PAPEROUT |
JOB_STATUS_BLOCKED_DEVQ))
{
KillTimer(1);
AfxMessageBox(pJobs[i].pDocument);
free( pJobs );
return ;
}
}
free( pJobs );
}
break;
default:
break;
}
用到的方法:
BOOL GetJobs(HANDLE hPrinter, /* Handle to the printer. */
JOB_INFO_2 **ppJobInfo, /* Pointer to be filled. */
int *pcJobs, /* Count of jobs filled. */
DWORD *pStatus) /* Print Queue status. */
{
DWORD cByteNeeded,
nReturned,
cByteUsed;
JOB_INFO_2 *pJobStorage = NULL;
PRINTER_INFO_2 *pPrinterInfo = NULL;
/* Get the buffer size needed. */
if (!GetPrinter(hPrinter, 2, NULL, 0, &cByteNeeded))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return FALSE;
}
pPrinterInfo = (PRINTER_INFO_2 *)malloc(cByteNeeded);
if (!(pPrinterInfo))
/* Failure to allocate memory. */
return FALSE;
LPCSTR str="sssssssssss";
/* Get the printer information. */
if (!GetPrinter(hPrinter,2,(unsigned char *)(LPSTR)pPrinterInfo,cByteNeeded,&cByteUsed))
{
/* Failure to access the printer. */
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
/* Get job storage space. */
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
NULL,
0,
(LPDWORD)&cByteNeeded,
(LPDWORD)&nReturned))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
}
pJobStorage = (JOB_INFO_2 *)malloc(cByteNeeded);
if (!pJobStorage)
{
/* Failure to allocate Job storage space. */
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
ZeroMemory(pJobStorage, cByteNeeded);
/* Get the list of jobs. */
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
(LPBYTE)pJobStorage,
cByteNeeded,
(LPDWORD)&cByteUsed,
(LPDWORD)&nReturned))
{
free(pPrinterInfo);
free(pJobStorage);
pJobStorage = NULL;
pPrinterInfo = NULL;
return FALSE;
}
/*
* Return the information.
*/
*pcJobs = nReturned;
*pStatus = pPrinterInfo->Status;
*ppJobInfo = pJobStorage;
free(pPrinterInfo);
return TRUE;
}
需要插入头文件#include <winspool.h>
posted @
2009-07-15 17:49 似水之心 阅读(5879) |
评论 (3) |
编辑 收藏