c++ - FTP client request failure -
i'm trying develop ftp protocol in c++. takes type of request client (get or put) however, server receives put request in both cases , none of functionality.
here code compare type of request:
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 type\n");
and part execute when request sent server:
if(smsg.type=req_get) { cout<<"iam inside get"<<endl; cout<<smsg.type<<endl; //send out message memcpy(smsg.buffer,&req,sizeof(req)); //copy request msg's buffer smsg.length=sizeof(req); fprintf(stdout,"send request %s\n",argv[1]); if (msg_send(sock,&smsg) != sizeof(req)) err_sys("sending req packet error.,exit"); //receive response if(msg_recv(sock,&rmsg)!=rmsg.length) err_sys("recv response error,exit"); //cast response structure respp=(resp *)rmsg.buffer; printf("response:%s\n\n\n",respp->response);}
when displaying "respp->response" doesn't return anything, , size of file zero.
does have idea how solve problem? highly appreciated.
- if(smsg.type=req_get) + if(smsg.type==req_get)
next time try use -wall when compiling, might catch kind of error
Comments
Post a Comment