![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
sending .zip files with winsock
could someone show me how to send .zip files over a connection using winsock? thanks for the help.
|
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
the same way you send anything else.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Binary data is just a series of bits, some in one state and some in another. You can't tell what the content is just by looking. The meaning of any data is established by external agreement and convention. A file with the extension, ".exe", is presumed to be a Windows executable file, but I can rename an Excel spreadsheet to that if I like. It probably won't do anything useful. Besides, there are other conventions internal to a file that Windows will examine before attempting to execute it. These conventions are USUALLY sufficient to establish the credentials of a file, but it isn't a done deal. A lot of file types have a "magic number" in the first couple of bytes, but it's certainly not impossible (or even greatly improbable) for the first two bytes of a file of random data to contain that pattern.
All this is the reason that lots of data transfer mechanisms wrap the information inside a protocol (sometimes, layers of protocols). It's just another convention that increases the probability that you interpret the data correctly and, sometimes, without error.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
can i just send the filename over the connection, or do i have to open the file read the data and send that over the connection?
|
|
|
|
|
|
#5 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
Otherwise, you read the file and send it over. Before you do that, though, send the length of the data in the file over the second computer, so that when you have finished sending the data over the second computer can check to see if it's got the correct amount of data (and so more or less a simple way of checking whether the file was sent correctly). |
|
|
|
|
|
|
#6 |
|
Professional Programmer
|
http://www.ecst.csuchico.edu/~beej/guide/net/
This is your bible, print it, read it, and sleep with it under your pillow. -Dizz |
|
|
|
|
|
#7 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
ok thanks
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|