Handling images in a proxy server written in C -


to receive requested web server , transmit client, doing following,

while(1) {         bzero(buffer,65536); //character buffer of 64kb         ret_val = recv(sockfd, buffer, 65535,0); //sockfd socket between web server , proxy server         if(ret_val < 0)              error("error reading data requested server");         send_ret_val = send_all(sock, buffer, strlen(buffer), 0);//sockfd socket between proxy server , client          if(send_ret_val < 0)            error("error returning data client");         if(ret_val == 0)             break; } 

the function send() transmits data there in buffer , returns 0 else returns negative value error.

the problem server seems working fine text data cannot handle images , other binary data. when using firefox, error, incompatible compression technique.

is there problem in code or there problem somewhere else?

strlen(buffer) truncates when found null character in buffer. image data binary data. binary data may contain null characters in middle of image. must use number of bytes received recv call send bytes client.

modify following statement

send_ret_val = send_all(sock, buffer, strlen(buffer), 0); 

to

send_ret_val = send_all(sock, buffer, ret_val, 0); 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -