1
votes

so this is a pretty basic concept question, but I'm new to this. I have successfully opened and connected a socket between my Windows computer and my Ubuntu lamp server. I want to send a .txt file through this socket onto the server via the Winsock Send function. Where do I tell the socket/send function which folder to put the location in? When I connected to the server, I just gave an IP address and port (ex:// 192.168.1.25 over port 80) and made the connection. Is there a way to tell it to put it in a specific location, like /var/local/storage/folder? I didn't see anything in either the send function of socket connection that specified an ending location?

Sorry if this is a newbie question. thanks in advance.

1

1 Answers

0
votes

HTTP clients are communicating with HTTP server through a TCP connection using HTTP protocol. The HTTP protocol is very simple but still there are many pitfalls to avoid when implementing a simple HTTP client or server so instead of simply writing the code that connects with TCP and communicates using HTTP it is easier to make use of a HTTP client library that does both the connection for you and also the composition/interpretation of HTTP protocol messages for you. One such popular crossplatform C library is libcurl but on windows you could also use the platform specific WinINet/WinHTTP functions. If you still insist on programming the HTTP communication for yourself using your own TCP connection that take a look at how the sent data of a file upload looks like by checking out the POST HTTP request in this answer: here

If you want to implement a HTTP client yourself then it is wise to check out how other HTTP clients (for example browsers) communicate with servers by capturing the communication using WireShark. Even if you don't want to implement the HTTP protocol it is very helpful to know the HTTP protocol at least on a basic level, it helps a lot even when using a pre-baked HTTP client.