Changeset 19 in libcf++
- Timestamp:
- 08/14/15 01:20:34 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf/net.h
r18 r19 1 1 /** 2 * @file net work.h2 * @file net.h 3 3 * @author myusgun@gmail.com 4 4 * @brief network … … 19 19 * network 20 20 */ 21 namespace net work21 namespace net 22 22 { 23 23 /** -
trunk/src/net.cpp
r18 r19 1 1 /** 2 * @file net work.cpp2 * @file net.cpp 3 3 * @author myusgun@gmail.com 4 4 * @brief network 5 5 */ 6 #include "cf/net work.h"6 #include "cf/net.h" 7 7 8 8 #include <iostream> … … 99 99 } 100 100 101 static cf::void_t setReuseAddress(const cf::net work::tcp & tcp)101 static cf::void_t setReuseAddress(const cf::net::tcp & tcp) 102 102 throw (cf::exception) 103 103 { … … 118 118 socklen_t *len); 119 119 120 static cf::net work::host getSocketNameFromFunction(const cf::socket_t sock,120 static cf::net::host getSocketNameFromFunction(const cf::socket_t sock, 121 121 getSocketNameAPI api) 122 122 throw (cf::exception) … … 132 132 << ")"); 133 133 134 return cf::net work::host(convertAddressToString(addr), addr.sin_port);134 return cf::net::host(convertAddressToString(addr), addr.sin_port); 135 135 } 136 136 /*--------------------------------------------------------------*/ 137 137 138 cf::net work::host::host(const std::string & address,138 cf::net::host::host(const std::string & address, 139 139 const cf::uint16_t port) 140 140 : mAddress(address), … … 143 143 } 144 144 145 const std::string & cf::net work::host::address() const145 const std::string & cf::net::host::address() const 146 146 { 147 147 return mAddress; 148 148 } 149 149 150 cf::uint16_t cf::net work::host::port() const150 cf::uint16_t cf::net::host::port() const 151 151 { 152 152 return mPort; 153 153 } 154 154 155 cf::net work::tcp::tcp(const cf::socket_t attachedSocket)155 cf::net::tcp::tcp(const cf::socket_t attachedSocket) 156 156 throw (cf::exception) 157 157 : mSocket (attachedSocket), … … 180 180 } 181 181 182 cf::net work::tcp::~tcp()182 cf::net::tcp::~tcp() 183 183 { 184 184 close(); 185 185 } 186 186 187 cf::socket_t cf::net work::tcp::descriptor() const187 cf::socket_t cf::net::tcp::descriptor() const 188 188 { 189 189 return mSocket; 190 190 } 191 191 192 cf::void_t cf::net work::tcp::close()192 cf::void_t cf::net::tcp::close() 193 193 { 194 194 if (mSocket == cf::nodesc) … … 200 200 } 201 201 202 cf::void_t cf::net work::tcp::connect(const cf::network::host & peer,202 cf::void_t cf::net::tcp::connect(const cf::net::host & peer, 203 203 const cf::int32_t timeout) 204 204 throw (cf::exception) … … 207 207 } 208 208 209 cf::void_t cf::net work::tcp::connect(const std::string & address,209 cf::void_t cf::net::tcp::connect(const std::string & address, 210 210 const cf::uint16_t port, 211 211 const cf::int32_t timeout) … … 270 270 } 271 271 272 cf::void_t cf::net work::tcp::bind(const cf::uint16_t port) const272 cf::void_t cf::net::tcp::bind(const cf::uint16_t port) const 273 273 throw (cf::exception) 274 274 { … … 299 299 } 300 300 301 cf::void_t cf::net work::tcp::listen(const cf::int32_t backlog) const301 cf::void_t cf::net::tcp::listen(const cf::int32_t backlog) const 302 302 throw (cf::exception) 303 303 { … … 307 307 } 308 308 309 cf::net work::tcp cf::network::tcp::accept() const309 cf::net::tcp cf::net::tcp::accept() const 310 310 throw (cf::exception) 311 311 { … … 318 318 THROW_EXCEPTION("cannot accept client"); 319 319 320 return cf::net work::tcp(sock).detach();321 } 322 323 cf::void_t cf::net work::tcp::attach(const cf::socket_t sock)320 return cf::net::tcp(sock).detach(); 321 } 322 323 cf::void_t cf::net::tcp::attach(const cf::socket_t sock) 324 324 throw (exception) 325 325 { … … 330 330 } 331 331 332 cf::socket_t cf::net work::tcp::detach()332 cf::socket_t cf::net::tcp::detach() 333 333 throw (exception) 334 334 { … … 343 343 } 344 344 345 cf::void_t cf::net work::tcp::send(const cf::bin & in) const345 cf::void_t cf::net::tcp::send(const cf::bin & in) const 346 346 throw (cf::exception) 347 347 { … … 357 357 } 358 358 359 cf::void_t cf::net work::tcp::receive(cf::bin & out) const359 cf::void_t cf::net::tcp::receive(cf::bin & out) const 360 360 throw (cf::exception) 361 361 { … … 384 384 } 385 385 386 cf::bin cf::net work::tcp::receive(const cf::int32_t size) const386 cf::bin cf::net::tcp::receive(const cf::int32_t size) const 387 387 throw (cf::exception) 388 388 { … … 395 395 } 396 396 397 cf::bin cf::net work::tcp::receive() const397 cf::bin cf::net::tcp::receive() const 398 398 throw (cf::exception) 399 399 { … … 414 414 } 415 415 416 cf::void_t cf::net work::tcp::getOption(const cf::int32_t optname,416 cf::void_t cf::net::tcp::getOption(const cf::int32_t optname, 417 417 cf::void_t * optval, 418 418 cf::int32_t * optlen) const … … 434 434 } 435 435 436 cf::void_t cf::net work::tcp::setOption(const cf::int32_t optname,436 cf::void_t cf::net::tcp::setOption(const cf::int32_t optname, 437 437 const cf::void_t * optval, 438 438 const cf::int32_t optlen) const … … 454 454 } 455 455 456 cf::void_t cf::net work::tcp::setNonBlocking(const cf::bool_t flag)456 cf::void_t cf::net::tcp::setNonBlocking(const cf::bool_t flag) 457 457 { 458 458 #ifdef _ON_WINDOWS … … 469 469 } 470 470 471 cf::void_t cf::net work::tcp::setTimeout(const cf::int32_t seconds)471 cf::void_t cf::net::tcp::setTimeout(const cf::int32_t seconds) 472 472 { 473 473 setNonBlocking(seconds > 0 /*? true : false*/); … … 475 475 } 476 476 477 cf::net work::host cf::network::tcp::peer() const477 cf::net::host cf::net::tcp::peer() const 478 478 throw (cf::exception) 479 479 { … … 488 488 } 489 489 490 cf::net work::host cf::network::tcp::local() const490 cf::net::host cf::net::tcp::local() const 491 491 throw (cf::exception) 492 492 { … … 501 501 } 502 502 503 std::string cf::net work::nic::getMACAddress()503 std::string cf::net::nic::getMACAddress() 504 504 throw (cf::exception) 505 505 { … … 529 529 530 530 531 cf::uint32_t cf::net work::byteOrder::htonl(cf::uint32_t in)531 cf::uint32_t cf::net::byteOrder::htonl(cf::uint32_t in) 532 532 { 533 533 return ::htonl(in); 534 534 } 535 535 536 cf::uint16_t cf::net work::byteOrder::htons(cf::uint16_t in)536 cf::uint16_t cf::net::byteOrder::htons(cf::uint16_t in) 537 537 { 538 538 return ::htons(in); 539 539 } 540 540 541 cf::uint32_t cf::net work::byteOrder::ntohl(cf::uint32_t in)541 cf::uint32_t cf::net::byteOrder::ntohl(cf::uint32_t in) 542 542 { 543 543 return ::ntohl(in); 544 544 } 545 545 546 cf::uint16_t cf::net work::byteOrder::ntohs(cf::uint16_t in)546 cf::uint16_t cf::net::byteOrder::ntohs(cf::uint16_t in) 547 547 { 548 548 return ::ntohs(in); -
trunk/test/test.cpp
r13 r19 6 6 #include "cf/task.h" 7 7 #include "cf/util.h" 8 #include "cf/net work.h"8 #include "cf/net.h" 9 9 10 10 #include <string> … … 158 158 { 159 159 std::cout << "H/W Address : " 160 << cf::net work::nic::getMACAddress()160 << cf::net::nic::getMACAddress() 161 161 << std::endl; 162 162 } … … 204 204 try 205 205 { 206 cf::net work::tcp server;207 cf::net work::tcp client;206 cf::net::tcp server; 207 cf::net::tcp client; 208 208 cf::bin msg; 209 209 … … 214 214 { 215 215 client.attach(server.accept().detach()); 216 cf::net work::host peer = client.peer();216 cf::net::host peer = client.peer(); 217 217 std::cout << "client <" 218 218 << peer.address() << ":" << peer.port() … … 242 242 try 243 243 { 244 cf::net work::tcp client;245 cf::net work::host host(HOST, PORT);244 cf::net::tcp client; 245 cf::net::host host(HOST, PORT); 246 246 247 247 cf::ulong_t tid = cf::task::thread::id(); -
trunk/windows/libcf++.sln
r4 r19 1 1 2 Microsoft Visual Studio Solution File, Format Version 10.00 3 # Visual Studio 2008 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcf++", "libcf++.vcproj", "{F6D565DE-91B5-46E1-AD17-2C7067C1DDCE}" 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 # Visual Studio 14 4 VisualStudioVersion = 14.0.23107.0 5 MinimumVisualStudioVersion = 10.0.40219.1 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcf++", "libcf++.vcxproj", "{F6D565DE-91B5-46E1-AD17-2C7067C1DDCE}" 5 7 EndProject 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{A5567A0F-56C8-404E-AB02-5E95C8EE6BC0}" 7 ProjectSection(ProjectDependencies) = postProject 8 {F6D565DE-91B5-46E1-AD17-2C7067C1DDCE} = {F6D565DE-91B5-46E1-AD17-2C7067C1DDCE} 9 EndProjectSection 8 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{A5567A0F-56C8-404E-AB02-5E95C8EE6BC0}" 10 9 EndProject 11 10 Global
Note:
See TracChangeset
for help on using the changeset viewer.