怎么把一个FORM 的内容get出去? 如题目 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我看不懂//Get html page by SDK socket#define host_name "www.csdn.net"#define winsock_version 0x0101void main(){ SOCKADDR_IN saServer; LPHOSTENT lphostent; WSADATA wsadata; SOCKET hsocket; int nRet; char hostname[100] ; wsprintf(hostname,"GET /expert/topic/378/378382.shtm HTTP/1.0 %c%c",10,10); printf("%s",hostname); char dest[1000]; if(WSAStartup(winsock_version,&wsadata)) printf("can't open"); lphostent=gethostbyname(host_name); if(lphostent==NULL) printf("lphostent is null"); hsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); saServer.sin_family = AF_INET; // Use def. now, need to handle general case saServer.sin_port = htons(80); saServer.sin_addr = *((LPIN_ADDR)*lphostent->h_addr_list); nRet = connect(hsocket, (LPSOCKADDR)&saServer, sizeof(SOCKADDR_IN)); if (nRet == SOCKET_ERROR) { printf("can't connect"); closesocket(hsocket); return; } else printf("connected with %s\n",host_name); nRet = send(hsocket, hostname, strlen(hostname), 0); if (nRet == SOCKET_ERROR) { printf("send() failed"); closesocket(hsocket); } else printf("send() OK\n"); nRet=1; while(nRet>0) { nRet=recv(hsocket,(LPSTR)dest,sizeof(dest),0); if(nRet>0) dest[nRet]=0; else dest[0]=0; printf("\nReceived bytes:%d\n",nRet); printf("Result:\n%s",dest); } }/////////////////////////////////////////////////////////////////////////////SDK post///////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "winsock.h"#pragma comment(lib,"ws2_32.lib")#define winsock_version 0x0101void main(){ //I create C:\Inetpub\wwwroot\test\test.asp ,start the web service //start my program, the result is OK. //If it works,it is written by masterz,otherwise I don't know who write it. SOCKADDR_IN saServer; LPHOSTENT lphostent; WSADATA wsadata; SOCKET hsocket; int nRet; const char* host_name="127.0.0.1"; char* req="POST /test/test.asp HTTP/1.0\r\n" "From: local\r\n" "User-Agent: post_test/1.0\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: 20\r\n\r\n" "type=12345&name=aaaa"; if(WSAStartup(winsock_version,&wsadata)) printf("can't initial socket"); lphostent=gethostbyname(host_name); if(lphostent==NULL) printf("lphostent is null"); hsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); saServer.sin_family = AF_INET; // Use def. now, need to handle general case saServer.sin_port = htons(80); saServer.sin_addr = *((LPIN_ADDR)*lphostent->h_addr_list); nRet = connect(hsocket, (LPSOCKADDR)&saServer, sizeof(SOCKADDR_IN)); if (nRet == SOCKET_ERROR) { printf("can't connect"); closesocket(hsocket); return; } else printf("connected with %s\n",host_name); nRet = send(hsocket, req, strlen(req), 0); if (nRet == SOCKET_ERROR) { printf("send() failed"); closesocket(hsocket); } else printf("send() OK\n"); char dest[1000]; nRet=1; while(nRet>0) { nRet=recv(hsocket,(LPSTR)dest,sizeof(dest),0); if(nRet>0) dest[nRet]=0; else dest[0]=0; printf("\nReceived bytes:%d\n",nRet); printf("Result:\n%s",dest); } } get发出去了,我又该怎么把结果收回来并显示出来呢? media player ocx 钩子函数问题 web opengl窗口中加滚动条的问题 请问,想把一个整数用CString类Format函数的转化成二进制字符串,第一个参数应该如何设置? 急!求点云三角化源码! 我来拉,新人报到!! 请问如何用CFileFind类得到文件的修改日期? 请bohut进来接分,我已经攒足了100分!!! 求清晰的《vc技术内幕(第四版)》中文版 怎么产生随机数?我急! 如何取出放在CDBVariant 里的布尔类型的值? 求救!编译错 不知能不能枚举出我的Access数据库里有哪些表?
//Get html page by SDK socket
#define host_name "www.csdn.net"
#define winsock_version 0x0101
void main()
{
SOCKADDR_IN saServer;
LPHOSTENT lphostent;
WSADATA wsadata;
SOCKET hsocket;
int nRet;
char hostname[100] ;
wsprintf(hostname,"GET /expert/topic/378/378382.shtm HTTP/1.0 %c%c",10,10);
printf("%s",hostname);
char dest[1000];
if(WSAStartup(winsock_version,&wsadata))
printf("can't open");
lphostent=gethostbyname(host_name);
if(lphostent==NULL)
printf("lphostent is null");
hsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
saServer.sin_family = AF_INET;
// Use def. now, need to handle general case
saServer.sin_port = htons(80);
saServer.sin_addr = *((LPIN_ADDR)*lphostent->h_addr_list);
nRet = connect(hsocket, (LPSOCKADDR)&saServer, sizeof(SOCKADDR_IN));
if (nRet == SOCKET_ERROR)
{
printf("can't connect");
closesocket(hsocket);
return;
}
else
printf("connected with %s\n",host_name);
nRet = send(hsocket, hostname, strlen(hostname), 0);
if (nRet == SOCKET_ERROR)
{
printf("send() failed");
closesocket(hsocket);
}
else
printf("send() OK\n");
nRet=1;
while(nRet>0)
{
nRet=recv(hsocket,(LPSTR)dest,sizeof(dest),0);
if(nRet>0)
dest[nRet]=0;
else
dest[0]=0;
printf("\nReceived bytes:%d\n",nRet);
printf("Result:\n%s",dest);
}
}///////////////////////////////////////////////////////////////////////////
//SDK post
///////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "winsock.h"
#pragma comment(lib,"ws2_32.lib")
#define winsock_version 0x0101
void main()
{
//I create C:\Inetpub\wwwroot\test\test.asp ,start the web service
//start my program, the result is OK.
//If it works,it is written by masterz,otherwise I don't know who write it.
SOCKADDR_IN saServer;
LPHOSTENT lphostent;
WSADATA wsadata;
SOCKET hsocket;
int nRet;
const char* host_name="127.0.0.1";
char* req="POST /test/test.asp HTTP/1.0\r\n"
"From: local\r\n"
"User-Agent: post_test/1.0\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: 20\r\n\r\n"
"type=12345&name=aaaa";
if(WSAStartup(winsock_version,&wsadata))
printf("can't initial socket");
lphostent=gethostbyname(host_name);
if(lphostent==NULL)
printf("lphostent is null");
hsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
saServer.sin_family = AF_INET;
// Use def. now, need to handle general case
saServer.sin_port = htons(80);
saServer.sin_addr = *((LPIN_ADDR)*lphostent->h_addr_list);
nRet = connect(hsocket, (LPSOCKADDR)&saServer, sizeof(SOCKADDR_IN));
if (nRet == SOCKET_ERROR)
{
printf("can't connect");
closesocket(hsocket);
return;
}
else
printf("connected with %s\n",host_name);
nRet = send(hsocket, req, strlen(req), 0);
if (nRet == SOCKET_ERROR)
{
printf("send() failed");
closesocket(hsocket);
}
else
printf("send() OK\n");
char dest[1000];
nRet=1;
while(nRet>0)
{
nRet=recv(hsocket,(LPSTR)dest,sizeof(dest),0);
if(nRet>0)
dest[nRet]=0;
else
dest[0]=0;
printf("\nReceived bytes:%d\n",nRet);
printf("Result:\n%s",dest);
}
}