#include
#include
#include <winsock.h> main(int argc,char *argv[]){
char buff[4096];
SOCKET sock;
SOCKADDR_IN addr; WSADATA wsa;
WORD wVersionRequested;
struct hostent *hs;
int count, len;
char *url="www.sample.com"; if (argc!=4) {printf("Error!\n"); return -1; }
len=(strlen(argv[1])+strlen(argv[2])+strlen(argv[3])+49); wVersionRequested = MAKEWORD( 2, 0 );
if (WSAStartup(wVersionRequested , &wsa)!=0)
{
printf("Winsock Initialization failed.\n"); return -1;
} if ((sock=socket(AF_INET,SOCK_STREAM,0))==INVALID_SOCKET){
printf("Can not create socket.\n"); return -1;
} addr.sin_family = AF_INET;
addr.sin_port = htons(80);
_snprintf(buff, 4096, "POST /cgi-bin/forum.cgi HTTP/1.1\r\n"
"Host: %s\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: %d\r\n"
"\r\n"
"action=add&Title=%s&URL=http://%s&yuzi=1&Description=%s\r\n",
url,
len,
argv[1],
argv[2],
argv[3]);
if ((addr.sin_addr.s_addr=inet_addr(url))==-1){
if ((hs=gethostbyname(url))==NULL){
printf("Can not resolve specified host.\n"); return -1;
} addr.sin_family = hs->h_addrtype;
memcpy((void *)&addr.sin_addr.s_addr,hs->h_addr,hs->h_length);
} if (connect(sock,(LPSOCKADDR)&addr,sizeof(addr))==SOCKET_ERROR){
printf("Can not connect to specified host.\n"); return -1;
}
send(sock,buff,strlen(buff),0);
recv(sock,buff,sizeof(buff),0);
closesocket(sock);
}
return 0;
}
解决方案 »
- 未将对象引用设置到对象的实例
- C#中,如果一个派生类同时拥有几个类的特性,如何建立继承关系?
- 如何调用QQ相册里的图片
- 关于ComboBox
- 一个抓取网页数据的问题
- 写测试报告有什么具体格式吗?请教中。。。。
- 用Udp做了个p2p聊天,可就是不好使,怎么搞的(付程序,给看看!)
- 读取EXCEL问题。一个EXCEL文件(工价表)里面有很多份工价表(2XX个Sheet),并且里面的格式都不太同。很难通过写程序把它导入到SQL中。:(
- 在机械行业里搞信息化有没有前途?
- 用c#写一个给qq好友发信息的程序。
- 在web页中怎么设置页面的接受键?(在线等!)
- 请教:子类中如何将基类的public方法改成private方法
sorry, I am familiar with c#, but I do not know C