FTP客户端请求失败

FTP client request failure

本文关键字:失败 请求 客户端 FTP      更新时间:2023-10-16

我正在尝试用c++开发FTP协议。它接受来自客户端的请求类型(get或put),然而,在这两种情况下,服务器总是接收put请求,而不执行任何功能。

下面是比较请求类型的代码:
if(strcmp(argv[3],"get")==0)
    smsg.type=REQ_GET; //REQ_TIME;
else if (strcmp(argv[3],"put")==0)
{
    smsg.type=REQ_PUT; //REQ_SIZE;
}
else err_sys("Wrong request typen");

,这是当get请求发送到服务器时执行的部分:

if(smsg.type=REQ_GET)
{
    cout<<"Iam inside get"<<endl;
    cout<<smsg.type<<endl;
    //send out GET message
    memcpy(smsg.buffer,&req,sizeof(req)); //copy the request to the msg's buffer
    smsg.length=sizeof(req);
    fprintf(stdout,"Send a GET request to %sn",argv[1]);
    if (msg_send(sock,&smsg) != sizeof(req))
        err_sys("Sending req packet error.,exit");
    //receive the response
    if(msg_recv(sock,&rmsg)!=rmsg.length)
        err_sys("recv response error,exit");
    //cast it to the response structure
    respp=(Resp *)rmsg.buffer;
    printf("Response:%snnn",respp->response);}

当显示"respp->response"时,它不返回任何东西,并且文件的大小始终为零。

谁有解决这个问题的办法?如有任何帮助,不胜感激。
- if(smsg.type=REQ_GET)
+ if(smsg.type==REQ_GET)

下次尝试在编译时使用-Wall,它可能会捕获这种错误