?
Solved

File Transfer using mswinsock control

Posted on 2002-03-14
6
Medium Priority
?
210 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 44

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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

752 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