View Full Version : C Networking

June 13th, 2009, 11:52 AM
Im writing a program which at some stage will need to connect to a server and then download a file. Im at a loss as to how to implement this as i have never done any programming that involves networking. Basically i will have two functions, connectToServer() and downloadFromServer(). I assume that i will need to open up a socket which is what i want the connectToServer() function to do, and then to use that socket to download what i want using downloadFromServer(). Right now i dont have access to this server so the file i want to download is stored locally at What i have so far:

#include <sys/types.h>
#include <sys/socket.h>

void connectToServer()
char *serverAddress = "";

void downloadFromServer()

As you can see i have pretty much nothing, but im hoping that someone here can help me.

June 13th, 2009, 12:24 PM
If only it were that easy....

You may want to peruse Beej's Guide to Network Programming (http://beej.us/guide/bgnet/) for details/examples.

June 13th, 2009, 01:53 PM
beej's guide is probably the best, but this one is quick and dirty to set up sockets

June 13th, 2009, 02:36 PM
Using libcurl i have been able to create an ftp client.

June 13th, 2009, 06:27 PM
Yeah, libcurl was probably a good call. No point in re-inventing wheels.