Click here to Skip to main content
15,889,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am sending a file from client to server in tcp/ip, in the receiving end, i am hard coding the file-name. Instead of this i would like to receive the same file name as it is in client. How can this be achieved in c programming? Can i have some sample code for further reference.
Posted
Comments
PIEBALDconsult 26-Nov-15 0:13am    
Is there some reason you can't use an established standard such as FTP or HTTP?
venkat28vk 26-Nov-15 0:56am    
No, i am told to use only in tcp/ip, is there any way for this?

1 solution

If you cant use FTP or HTTP as PIEBALDconsult suggests (or even Kermit) you'd likely have to derive your own 'mini protocol' - ie,

1) Header = send a fixed length filename and the number of bytes in the file, maybe a checksum as well
2) Data = send the file as bytes
3) Response = receive a response back when its been received and acknowledged (# bytes, checksum)

(but all this is re-inventing the wheel, surely)

'g'
 
Share this answer
 
Comments
PIEBALDconsult 26-Nov-15 10:44am    
I concur.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900