Chinaunix首页 | 论坛 | 博客
  • 博客访问: 845047
  • 博文数量: 133
  • 博客积分: 7117
  • 博客等级: 少将
  • 技术积分: 1846
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-16 21:30
文章分类

全部博文(133)

文章存档

2012年(1)

2011年(4)

2010年(2)

2009年(57)

2008年(69)

分类: 系统运维

2009-05-22 09:30:40

0.模拟器上,初始化需要先调用soc_init_win32()
1.监视MSG_ID_APP_SOC_NOTIFY_IND消息(SOC_WRITE,SOC_READ,SOC_CONNECT,SOC_CLOSE)
2.soc_create的最后一个参数:cmnet帐号默认是10,cmwap是14. 模拟器上随便都没问题.只要PC能上网.
3.soc_setsockopt  SOC_NBIO 设置不阻塞
4.soc_setsockopt  SOC_ASYNC 设置异步
5.soc_connect,soc_write,soc_read返回SOC_WOULDBLOCK必须等1的通知函数进行处理.最好设置超时来close socket.
6.数据的任意指针转化成short,int
   arm的特性,short指针必须2对齐,int指针必须4对齐.
   来自于网络的紧凑数据(packed data),必须支持任意地址转换成short或者int

static int  MyInt(unsigned char * p)
{
 int a ;
 ((unsigned char *)&a)[0] = p[0] ;
 ((unsigned char *)&a)[1] = p[1] ;
 ((unsigned char *)&a)[2] = p[2] ;
 ((unsigned char *)&a)[3] = p[3] ;
 return a ;
}

static  short MyShort(unsigned char * p)
{
 short a ;
 ((unsigned char *)&a)[0] = p[0] ;
 ((unsigned char *)&a)[1] = p[1] ;
 return a ;
}


7.cmwap的http协议模拟
   cmwap必须通过10.0.0.172:80端口进行代理
   走http协议.一般是1.1

#define      ProxyHttpRequestHeader  "POST / HTTP/1.1\r\n" "X-Online-Host: \r\n" "Keep-Alive: close\r\n" "Content-Length: %d\r\n" "\r\n"
// X-Online-Host后面跟着的就是目标机器网络地址和端口
// Content-Length 后面填写随后的数据长度
// 头部后面跟着就是随后数据,最好使用base64编码.
// 服务器端收到数据一般经过移动网关修改.


8.cmwap的http模拟: 服务器端返回格式:

#define HTTP_RESPONSE_HEADER  "HTTP/1.1 200 OK\r\n" "Content-Length: %d\r\n" "\r\n"

// Content-Length 后面填写随后的数据长度
// 头部后面跟着就是随后数据,最好使用base64编码.
阅读(5323) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~