How can i use SocketStream send multi files one time on one socket?

Please post support and help requests here.
coolzdp
Posts: 8
Joined: 12 Jan 2008, 05:04
Location: China

How can i use SocketStream send multi files one time on one socket?

Postby coolzdp » 21 Jan 2008, 14:55

Have some good examples?
I wrote these codes, by it doesn't work.

Code: Select all


StreamSocket ss;
         SocketStream str(ss);
         unsigned short port = 1970;
         std::string path = "c:\index.html";

         ss.connect(SocketAddress("localhost", port));

         str << path;
         str.flush();

         Poco::FileOutputStream fos("c:\get_index.html");
         StreamCopier::copyStream(str, fos);
         str.flush();
         fos.close();

         str << "c:\test.pdf";
         str.flush();

         Poco::FileOutputStream fos2("c:\get_test.pdf");
         StreamCopier::copyStream(str, fos2);
         str.flush();
         fos2.close();

         ss.close();

coolzdp
Posts: 8
Joined: 12 Jan 2008, 05:04
Location: China

Re: How can i use SocketStream send multi files one time on one socket?

Postby coolzdp » 21 Jan 2008, 14:59

again ~~

alex
Posts: 1246
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How can i use SocketStream send multi files one time on one socket?

Postby alex » 21 Jan 2008, 19:04

> Have some good examples?

> I wrote these codes, by it doesn't work.

Your code probably hangs because you are not calling shutdownSend() on the socket.

DialogSocket may be a better match for your purpose. see this post.

Alex

guenter
Posts: 1184
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: How can i use SocketStream send multi files one time on one socket?

Postby guenter » 22 Jan 2008, 07:58

You haven't shown us the code that receives the files. Also, with the way you're sending files, the receiving program has no way to tell where one file starts and the other endes. You may want to consider sending some length information along with file names and contents.
Furthermore, you might want to tell us specifically what does not work with your program.

coolzdp
Posts: 8
Joined: 12 Jan 2008, 05:04
Location: China

Re: How can i use SocketStream send multi files one time on one socket?

Postby coolzdp » 24 Jan 2008, 03:55

I got it, i should get the file size before read the data by SocketStream,
then download according to the size.
thanks!


Return to “Support”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

cron