資源簡介
不一下子應(yīng)用MFC等界面,以直觀易懂的控制臺程序展現(xiàn)網(wǎng)絡(luò)編程“服務(wù)端”-“客戶端”是怎么運(yùn)行的。最適合初學(xué)者。

代碼片段和文件信息
//?BoostAsioClientServer.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#ifdef?_MSC_VER
#define?_WIN32_WINNT????????0X0501????
#endif
#define?BOOST_REGEX_NO_LIB
#define?BOOST_DATE_TIME_SOURCE
#define?BOOST_SYSTEM_NO_LIB
#include?“stdafx.h“
#include?
#include?
#include?
//#include?
using?namespace?std;
//using?namespace?boost;
using?namespace?boost::asio;
//Functions?declaration
//void?client_server(?io_service?&io_s?);
int?_tmain(int?argc?_TCHAR*?argv[])
try
{
???????io_service?io_s;
???????boost::system::error_code?e_c;
???????cout?<“...Client?start...\n“;
//Create?client?socket?object
ip::tcp::socket?client_socket(?io_s?);
//Create?connect?port
ip::tcp::endpoint?client_ep(?ip::address::from_string(?“127.0.0.1“)?55?);
//Socket?connect?to?a?port
client_socket.connect(?client_ep?e_c?);
if(?e_c?)
{
throw?boost::system::system_error(?e_c?);
}
vector?str(?100?0?);
while(?true?)?
{??????
???????//Receive?message?from?server
???????client_socket.read_some(?buffer(?str?)?e_c?);
???????
???????//Check?if?disconnect?with?server
???????if?(?e_c?==?boost::asio::error::eof?)
???????{
???????break;
???????}
???????else?if?(?e_c?)
???????{
???????throw?boost::system::system_error(?e_c?);
???????}
???????//Print?infor?read?justnow
???????cout?<“\nreceive?form“?< ???????cout?<?&str[0]<“\n“;
???????
???????memset(?&str[0]?0?str.size()?);
???????
???????cout?<“my?reply?is:>>?Silent!\n“;
???????//Send
???????client_socket.write_some(?buffer(?“您好我現(xiàn)在有事不在,一會兒跟您聯(lián)系!“)?);
???????}
????????getchar();
return?0;
}
catch(?std::exception?&e?)
{
????????cout?<}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1875??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\BoostAsioClientServer.cpp
?????文件???????4661??2013-08-15?10:51??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\BoostAsioClientServer.vcxproj
?????文件???????1345??2013-08-15?10:32??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\BoostAsioClientServer.vcxproj.filters
?????文件????????143??2013-08-15?10:32??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\BoostAsioClientServer.vcxproj.user
?????文件????????406??2013-08-15?11:02??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.exe.em
?????文件????????472??2013-08-15?11:02??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.exe.em
?????文件????????381??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.exe.intermediate.manifest
?????文件?????????72??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.lastbuildstate
?????文件???????4167??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.log
?????文件????1148236??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.obj
?????文件????1179648??2013-08-15?10:51??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.pch
?????文件????????707??2013-08-15?10:51??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.vcxprojResolveAssemblyReference.cache
?????文件??????????0??2013-08-15?10:51??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer.write.1.tlog
?????文件????????232??2013-08-15?11:02??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\BoostAsioClientServer_manifest.rc
?????文件???????1738??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\cl.command.1.tlog
?????文件?????146312??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\CL.read.1.tlog
?????文件???????1174??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\CL.write.1.tlog
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
?????文件??????????2??2013-08-15?19:52??C++?Boost庫ASIO實(shí)現(xiàn)的簡單的網(wǎng)絡(luò)編程程序\源代碼\BoostAsioClientServer\BoostAsioClientServer\Debug\li
............此處省略142個(gè)文件信息
評論
共有 條評論