Solved

File Transfer using mswinsock control

Posted on 2002-03-14
6
207 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 100 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 92
ORA-01403: no data found 43 115
either24  challenge 19 107
canBalance challenge 34 109
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

738 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