Skip to content

Instantly share code, notes, and snippets.

@jgautsch
Created October 3, 2013 06:22
Show Gist options
  • Save jgautsch/6805813 to your computer and use it in GitHub Desktop.
Save jgautsch/6805813 to your computer and use it in GitHub Desktop.
sending name to ftp server
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Interacting with server
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char *file_name = argv[3];
/* First send the length of the file name */
short int file_name_length = strlen(file_name);
if (send(sock, &file_name_length, sizeof(file_name_length), 0) <= 0)
DieWithError("send() sent a different number of bytes than expected");
/* Next send the actual file name */
// char *file_name = "smallFile.html";
file_name_length = htons(file_name_length);
printf("Filename length: %d\n", file_name_length);
printf("Filename: %s\n", file_name);
if (send(sock, file_name, strlen(file_name), 0) <= 0)
DieWithError("second send() failed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment