socket编程 通讯协议tcp,数据承载协议http
2011-04-11 19:37
411 查看
sprintf(post, "POST /PURegister HTTP/1.1/r/n");
sprintf(accept, "Accept:*/*/r/n");
sprintf(accept_language, "Accept-Language: zh-cn/r/n");
sprintf(seq, "Seq:%d/r/n", 1);
sprintf(content_type, "Content-Type: application/x-www-form-urlencoded/r/n");
sprintf(user_agent, "User-Agent:Mozilla/4.0/r/n");
sprintf(host, "Host: %s:%d/r/n", SERVIP, SERVPORT);
sprintf(cookie, "Cookie: sessionId=%s/r/n", "");
sprintf(httpdata, "PUID=%s&puIp=%s&puPort=%d&puName=%s&puPassword=%s&puType=%d&videoSum=%d&CMUIP=%s", httpreg.PUID, httpreg.puIp, httpreg.puPort, httpreg.puName, httpreg.puPassword, httpreg.puType, httpreg.videoSum, httpreg.CMUIP);
//sprintf(httpdata, "PUID=%s&CMUIP=%s&puIp=%s&puPort=%d&puName=%s&puPassword=%s&conType=%d&puType=%d&videoSum=%d", httpreg.PUID, httpreg.CMUIP,httpreg.puIp, httpreg.puPort, httpreg.puName, httpreg.puPassword, 1,httpreg.puType, httpreg.videoSum);
len = strlen(httpdata);
sprintf(content_length, "Content-Length: %d/r/n/r/n", len);
printf("hihi:::%s/n", httpdata);
strcpy(httpmsg, post);
strcat(httpmsg, accept);
strcat(httpmsg, accept_language);
strcat(httpmsg, seq);
strcat(httpmsg, content_type);
strcat(httpmsg, user_agent);
strcat(httpmsg, host);
strcat(httpmsg, cookie);
strcat(httpmsg, content_length);
//strcat(httpmsg, "/n"); //这一个多余的行很害人
strcat(httpmsg, httpdata);
printf("%s/n", httpmsg);
sprintf(accept, "Accept:*/*/r/n");
sprintf(accept_language, "Accept-Language: zh-cn/r/n");
sprintf(seq, "Seq:%d/r/n", 1);
sprintf(content_type, "Content-Type: application/x-www-form-urlencoded/r/n");
sprintf(user_agent, "User-Agent:Mozilla/4.0/r/n");
sprintf(host, "Host: %s:%d/r/n", SERVIP, SERVPORT);
sprintf(cookie, "Cookie: sessionId=%s/r/n", "");
sprintf(httpdata, "PUID=%s&puIp=%s&puPort=%d&puName=%s&puPassword=%s&puType=%d&videoSum=%d&CMUIP=%s", httpreg.PUID, httpreg.puIp, httpreg.puPort, httpreg.puName, httpreg.puPassword, httpreg.puType, httpreg.videoSum, httpreg.CMUIP);
//sprintf(httpdata, "PUID=%s&CMUIP=%s&puIp=%s&puPort=%d&puName=%s&puPassword=%s&conType=%d&puType=%d&videoSum=%d", httpreg.PUID, httpreg.CMUIP,httpreg.puIp, httpreg.puPort, httpreg.puName, httpreg.puPassword, 1,httpreg.puType, httpreg.videoSum);
len = strlen(httpdata);
sprintf(content_length, "Content-Length: %d/r/n/r/n", len);
printf("hihi:::%s/n", httpdata);
strcpy(httpmsg, post);
strcat(httpmsg, accept);
strcat(httpmsg, accept_language);
strcat(httpmsg, seq);
strcat(httpmsg, content_type);
strcat(httpmsg, user_agent);
strcat(httpmsg, host);
strcat(httpmsg, cookie);
strcat(httpmsg, content_length);
//strcat(httpmsg, "/n"); //这一个多余的行很害人
strcat(httpmsg, httpdata);
printf("%s/n", httpmsg);
相关文章推荐
- 网络层、传输层、应用层、端口通信协议编程接口 - http,socket,tcp/ip 网络传输与通讯知识总结
- Socket网络编程,TCP/IP和Http等网络协议理解
- 在C#中使用异步Socket编程实现TCP网络服务的C/S的通讯构架(一)----基础类库部分(来源:http://blog.csdn.net/yangjundeng/archive/2005/03/17/321920.aspx)
- 从数据长征和网络协议对TCP/IP,http,socket 进行概念梳理
- Java系列-Socket网络编程,TCP/IP和Http等网络协议理解
- SOCKET,TCP/UDP,HTTP,FTP网络协议之间的关系
- 各协议(TCP/IP、UDP、HTTP、socket)内与外简述
- Linux Socket编程:基于TCP/IP的客户端与服务端通讯实例
- java中进行socket编程实现tcp、udp协议总结
- 网络编程--Socket、TCP/IP、UDP、Http之间的关系
- C#中使用异步Socket编程实现TCP网络服务的C/S的通讯构架(一)
- 在C++ Builder中用socket api来写网络通讯程序(同时支持TCP和UDP协议)
- 在C#中使用异步Socket编程实现TCP网络服务的C/S的通讯构架(二)----使用方法
- 聊聊Socket、TCP/IP、HTTP、FTP及网络编程
- 【协议】1、tcp,http,socket协议介绍
- HTTP/TCP/SOCKET连接协议和原理
- 《java入门第一季》之tcp协议下的编程实现键盘录入数据不断地往服务器端发送数据案例
- 网络协议(http/tcp/ip/socket)请求与服务
- 门面模式的典型应用 Socket 和 Http(post,get)、TCP/IP 协议的关系总结
- 基于SOCKET机制的TCP协议通讯