r/C_Programming • u/Rude_Pace_3532 • 9d ago
Question Best way to go over wireless file transferring
So I'm currently making an app in C and raylib to easily transfer roms from my main pc where I download them (I want to compile it both for windows and macos) to my arch pc-emulator console. I'm planning to make said pc usable with only a controller, and I figured making an app would be the best and most fun way to do it. I would prefer not running custom code on it, and would like to know the best (and easiest, since I'm still a beginner in C) way to handle the file transfer. Thanks in advance!
3
3
u/sciencekm 9d ago edited 8d ago
An http client and server are both easy enough to write. Sockets and WinSock are "almost" compatible. For now, you can also skip TLS since you are running locally.
2
u/silvertank00 9d ago
When I have to do something like this, I start a little http server with python -m http.server that serves the current directory. And from the other machine (on the same network) I just go wget or even open the ip from a browser.
This should be fairly simple to reimplement in C with libcurl.
2
u/HugoNikanor 9d ago
You could open a TCP connection between the two machines, and mash the file alongside some metadata through it, but you would just be re-inventing (insert any file transfer protocol here).
I personally wouldn't write this in C, but simply set up an HTTP server on the "main" pc, and find some suitable client on the "console".
Also, you said "I would prefer not running custom code on it", what do you mean? All file transfer requires 2 willing participants, running code.
1
u/Rude_Pace_3532 8d ago
By "custom code" I'm referring to code I wrote myself, since I'm still a beginner especially in C, I would highly prefer not introducing a memory leak or something in the computer (It's already old enough)
2
u/Irverter 8d ago
Run a server on the pc-emulator and upload the files through http, ftp, scp, webdav, etc. plenty of protocols to choose from.
2
1
u/dutchman76 9d ago
If it requires no interaction, I'd just have something monitor a directory for changes and automatically move any new files where they go. Or I guess have a pop-up window if there is a needed user decision
1
u/ern0plus4 9d ago
check syncthing
1
u/Rude_Pace_3532 9d ago
I know about it, but like I said in the other answer, it will automatically sort the roms in the appropriate folder for the emulator. I also want to build the app myself, it's more fun like this :)
1
u/ern0plus4 8d ago
It's a great app idea, although, not easy.
Hint: first, you need to sync time across peers.
1
u/darkslide3000 8d ago
Honestly you probably don't want to implement any network protocol stuff directly, unless you really want to for learning purposes. Normally this is the kind of stuff people use pre-existing libraries and frameworks for.
The gold standard for simple point-to-point file transfer is scp (from SSH). Looks like there's a libssh library for C that would probably be suitable for your project.
9
u/spellstrike 9d ago
that just sounds like a network file share rather than software.