CSocket问题?为什么POST第一次可以,第二次就失败?(RedCoral)
int len,res;
char temp[32];
CString msg="";
CString head="";
msg+="t1=\"";
msg+=m_edit1;
msg+="\"";
msg+="\r\n&B1=提交\r\n";//
head+="POST /post.asp HTTP/1.0 \r\n";
head+="Accept:image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,*/* \r\n";
head+="Content-Type:application/x-www-form-rulencoded \r\n";
head+="User-Agent:(compatible) \r\n";
head+="content-Length:";
len=strlen((LPCTSTR)msg);
itoa(len,temp,10);
head+=temp;
head+="\r\n\r\n";
sock.Close();
res=sock.Create();
res=sock.Connect("192.168.0.1",1010);
if (!res){
return;
}else
{
::MessageBox(m_hWnd,head,"",MB_OK);
::MessageBox(m_hWnd,msg,"",MB_OK);
sock.Send(head,strlen((LPCTSTR)head));
sock.Send(msg,strlen((LPCTSTR)msg));
res+=sock.Receive(temp,sizeof(temp));
if (res>16)
{
if (temp[13]=='O'&&temp[14]=='K')
{
::MessageBox(m_hWnd,"成功","提交信息",MB_OK+MB_ICONINFORMATION);
}
else
{
::MessageBox(m_hWnd,"失败","提交信息",MB_OK+MB_ICONINFORMATION);
}
}
}
sock.Close();
多谢了!