Jaishree Posted January 19, 2009 Share Posted January 19, 2009 Problem: when we are sending HTTP POST request (From C++ Program)- Connection got closed with "Connection reset by peer" mesaage after 5 transfers. But , when we are doing a POST msg in the web browser, the same message getting accepted by apache. Not sure whether we are doing mistake in setting up the connection or some thing else. Appriciate your time and advise on this. Thanks The c++ code snipet given below FYR... { sprintf(request,"POST /app-srv/read HTTP/1.1\r\nHost: 101.1.1.2:8080\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070718 Red Hat/1.5.0.12-3.el5 Firefox/1.5.0.12\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nReferer: http://101.1.1.2:8080/app-srv/\r\ntreemenu=none open\r\n"); strcpy(hostname,HOST); if (argc>2) { strcpy(hostname,argv[2]); } /* go find out about the desired host machine */ if ((hp = gethostbyname(hostname)) == 0) { perror("gethostbyname"); exit(1); } /* fill in the socket structure with host information */ memset(&pin, 0, sizeof(pin)); pin.sin_family = AF_INET; pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; pin.sin_port = htons(PORT); /* grab an Internet domain socket */ if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } /* connect to PORT on HOST */ if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) { perror("connect"); exit(1); } //Set Socket option if(setsockopt(sd, SOL_SOCKET,SO_KEEPALIVE,(const char*)&reuseFlag, sizeof reuseFlag) <0) { perror("set sockopt"); exit(1); } /* send a message to the server PORT on machine HOST */ if (send(sd, request, strlen(request), 0) != strlen(request)) { perror("send"); exit(1); } sprintf(request,"Content-Type: application/x-www-form-urlencoded\r\nContent-Length: 11986\r\n?xmlvalues= <test>................</test>"); // Very long - post string of size 11986... Not shown the sting fully in this line if (send(sd, request, strlen(request), 0) != strlen(request)) { perror("send"); exit(1); } l=recv(sd,dir,DIRSIZE,0); if ( l== -1) { //done=1; perror("recv"); exit(1); } /* spew-out the results and bail out of here! */ close(sd); } Quote Link to comment Share on other sites More sharing options...
corbin Posted January 19, 2009 Share Posted January 19, 2009 http://www.phpfreaks.com/forums/index.php/topic,234163.msg1087458.html#msg1087458 Did you not believe me the first time? But, if that's not it, try outputting the stuff that you're sending. Maybe you're missing a linebreak somewhere or something. Quote Link to comment Share on other sites More sharing options...
Jaishree Posted January 19, 2009 Author Share Posted January 19, 2009 http://www.phpfreaks.com/forums/index.php/topic,234163.msg1087458.html#msg1087458 Did you not believe me the first time? But, if that's not it, try outputting the stuff that you're sending. Maybe you're missing a linebreak somewhere or something. Thanks Corbin I tried it out since i belived But it didn't work I set "KeepAlive: On" & "maxNumberof connection :100" in httpd.conf i guess the way proceed was correct is it so? is there any specific linebreaks that should be given after some bytes in the POST message ?? Thank you Quote Link to comment Share on other sites More sharing options...
corbin Posted January 19, 2009 Share Posted January 19, 2009 No, I meant maybe you're not following HTTP specifications, but I don't think that's it since it wouldn't work for 5 requests. I set "KeepAlive: On" & "maxNumberof connection :100" Those are valid httpd.conf flags x.x. Quote Link to comment Share on other sites More sharing options...
Jaishree Posted January 20, 2009 Author Share Posted January 20, 2009 While sending more than 8192 Bytes of data , Reset Happens. Is it related to "LimitRequestBody" Directive ??? If so , where i need to set this in Apache HTTP Server?? Quote Link to comment Share on other sites More sharing options...
corbin Posted January 21, 2009 Share Posted January 21, 2009 httpd.conf Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.