I have searched for a neat explanation of how to use sockets to receive and send files in linux, but i can't find a solution that even works a little bit. I have a c++ server on linux, and a client which runs in java.
I need it to do the following:
- Client needs to be able to send text-commands towards the server.
- Client needs to be able to send/receive files towards the server.
- Server gets the following command when receiving a file: PUT < saveLocation > < filecontents >
- Everything gets closed by "\n".
I've got a lot of code written already, and am able to send commands back and forth between client and server. But now i'm stuck on sending/receiving a file on both the client and server.
What steps should i take, to be able to receive a command from the client which says "PUT /map1/test.pdf somefile" and also receive the actual file?
If code is needed pls ask, and i'll post it, but i don't which code blocks can be helpful.
Everything gets closed by "\n".you have two big restrictions. You can't send binary files and you can't send text with more than one line. I would rethink the protocol.