Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending objects

Status
Not open for further replies.

mohansekar

Programmer
Jul 6, 2001
23
IN
Hi there,

Can anybody tell me how to transfer an image from one m/c to another using winsockets. The image is of the type .BMP/JPEG.

thanx in advance

bye
 
On the receiving computer you open a socket in listen mode. On the sending computer you open a socket in send mode to connect to the listening computer. You then open your image file in "binary" mode, and send the bytes through the winsock connection.

You'll want to send some info ahead of the file itself so the other computer knows the filename, the filedate, and most importantly, the size of the file. TCP sends data as a continuous stream, and doesn't know anything about the size of things (it's all just bytes to it), so you need to tell the computer at the other end how many bytes to expect. If you tell it too small, the file gets chopped off. If you tell it too large, it hangs, waiting for those bytes which will never be sent.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top