Socket programming help......

gabel1

Baseband Member
Messages
29
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.
 
I suggest that you implement some kind of specal charectors, or escape sequence,

for examlpe send
"~file~"
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.
 
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.
 
you can always find an open source ftp deamon and view the source code... probably won't be in c# though.
 
Back
Top Bottom