954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

socket programing

hey.
can i transfer pictures through sockets using c++? how can i do it if its posible.

sidra 100
Junior Poster
142 posts since Dec 2009
Reputation Points: 6
Solved Threads: 0
 

It's easier with a library that abstracts the complicated socket stuff.

Right now I would probably consider using boost for it (personally).

#include <boost/asio.hpp>

void TransferData( std::string data )
{
   //Server/port.
   boost::asio::ip::tcp::iostream con("server","9001");//or protocol, like "HTTP"
   if( !con )
      ;//Connecting failed or something.
   else
      con << "Ehlo their mate. Have sum datums." << data << std::flush;
   con.close();
}


You can find an installer for boost here: www.boostpro.com
Then in your project settings -> include directories,
add the main boost folder to the include directories
and the "lib" folder to the lib directories.

pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: