Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 10-22-2005, 10:18 PM   #1
Baseband Member
Join Date: Sep 2005
Posts: 29
Default Socket programming help......

i created socket programs in C#(client/server) and i have them being able to chat now b/w each other. what i want to do now is exchange files between them. can someone please direct me in the right direction of how to implement this? can you send any files? (e.g., .jpeg, .pdf, etc.) thanks.

gabel1 is offline   Reply With Quote
Old 10-24-2005, 03:52 AM   #2
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 7,872
Default Re: Socket programming help......

I suggest that you implement some kind of specal charectors, or escape sequence,

for examlpe send
then the filename,
then send "~content~"
read the source file byte by byte sending each byte to the sockets pipe, once this is finished send "~end~".

As far as I am aware there is no way to just mark a file to be delivered.

I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 11-11-2005, 10:34 PM   #3
Solid State Member
Join Date: Nov 2005
Posts: 17
Default Re: Socket programming help......

Open a file stream (not sure about how this is done in C#, been a while) in binary mode. Load the entire file into a buffer. Files normally end with a EOF (end of file) character. Send the file buffer byte by byte until an EOF is reached. Send the EOF too and have the client stop recieving when it reaches an EOF.
Grundee is offline   Reply With Quote
Old 11-14-2005, 03:32 PM   #4
Daemon Poster
RewtGuy's Avatar
Join Date: Dec 2004
Posts: 595
Send a message via AIM to RewtGuy
Default Re: Socket programming help......

you can always find an open source ftp deamon and view the source code... probably won't be in c# though.
Windows: A thirty-two bit extension and GUI shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor and sold by a two-bit company that can't stand one bit of competition.
RewtGuy is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 11:56 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0