我正在学习winsock2,我用它做了我自己的聊天程序。现在我想知道是否有可能制作一个可以连接到FTP服务器并上传文件的程序。我在网上找到了许多“教程”,但它们似乎都使用自己的库,而不是winsock2。
如何使用winsock2连接FTP?
发布于 2011-09-15 01:10:39
阅读有关FTP协议的内容。当连接到FTP服务器时,所有的不同之处在于有关于发送什么信号的规则,因为协议描述了这些规则。
For information about the signals and structure of messages
登录到ftp服务器的示例假设sock是连接到ftp服务器的ftp端口(21)的套接字。
char loginMsg[] = "USER MyName\r\nPASS MyPass\r\n";
char responce[4] = {'\0'};
send(sock, loginMsg, strlen(loginMsg), 0);
recv(sock, responce, 3, 0);
if (strcmp(responce, "230") != 0)
// Could not log in to the ftp serverhttps://stackoverflow.com/questions/7420183
复制相似问题