C socket programming, how to login the remote FTP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C socket programming, how to login the remote FTP

plodosplodos Posts: 2Member
I can connect the remote site by the help of this code.
But How can I login the ftp.ciu.edu.tr with my username and my password?
Can any body give me a hint or link ?
If there are guys or girls who has done similar things, please help me
Thanks in advance
[code]#include
#include
#include
#include
#pragma comment(lib, "wsock32.lib")
int main(int argc, char** argv)
{
WSADATA WSAData;
struct hostent* HostEnt;
SOCKET Socket;
struct sockaddr_in ServerInfo;
WSAStartup(0x202, &WSAData);
HostEnt = gethostbyname("ftp.ciu.edu.tr");
if (HostEnt == NULL)
{
printf("Unable to get the host information.
");
WSACleanup();
return -1;
}
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (Socket == INVALID_SOCKET)
{
printf("Unable to create the socket.
");
WSACleanup();
return -1;
}
memset(&ServerInfo, 0, sizeof(ServerInfo));
memcpy(&ServerInfo.sin_addr, HostEnt->h_addr, HostEnt->h_length);
ServerInfo.sin_family = HostEnt->h_addrtype; // Always AF_INET
ServerInfo.sin_port = htons(80);
if (connect(Socket, (struct sockaddr*) &ServerInfo, sizeof(ServerInfo)) == -1)
{
printf("Unable to connect to the server.
");
WSACleanup();
return -1;
}

printf("Successfully connected to the server!
");
closesocket(Socket);
WSACleanup();
return 0;
}
[/code]
Sign In or Register to comment.