Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File Transfer using mswinsock control

Posted on 2002-03-14
6
Medium Priority
?
212 Views
Last Modified: 2013-11-20
Dear friends
I want to transfer a file thru a socket created with winsock control.  I am able to transfer only text files and I donno how to transfer other files (image files in specific).  Please let me know abt this as soon as possible.

-Venkataramanan
0
Comment
Question by:venkataramanan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6867429
The actions are identical.  If you can do one, you can do the other -- there is nothing that needs to be explained.

Describe what problem you are having.  Show the code that malfunctions and describe what it is doing that you would want it to do differently.

-- Dan
0
 

Author Comment

by:venkataramanan
ID: 6867610
Dear Don
The data to be sent thru a socket should be put into a variant.  For text files, i read some 10 characters as a BSTR and set the variant type to VT_BSTR and it is received in the other end in a variant and extracted from "pbstrVal" member of the variant.  If i try this for other file types, it is not received correctly at the other end.

For other file types Pls tell me to which member of  the variant i have to put the file contents (which are read as a BSTR)and from which member I have to extract in the recieving end.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6868622
BSTR can contain binary data.  Just read chinks of data from the file and send it sa you have been.  When you receive it, be sure to copy the BSTR data to a byte array rather than (for instance) a CString object.  A CString object will truncate the data at the first NULL (0x00) thaat it encounters.

Show the code that you are using when you receive the data and I will try to see what is malfunctioning.

-- Dan
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 400 total points
ID: 6868642
An alternative would be to convert the binary data into text before you send it and then convert the text to binary data when you receive it.  

One simple method is to convert each byte into two hex digits.  Another method is to base64 encode the entire file.  But since these options increase the size of the transmission, it would be best to try to keep the binary data as binary data.

-- Dan
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 10401876
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept DanRollins
Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

AndyAinscow
EE Cleanup Volunteer

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question