0. On the emulator, initialization requires the first call to Soc_init_win32 ()
1. Monitoring Msg_id_app_soc_notify_ind messages (Soc_write,soc_read,soc_connect,soc_close)
The last parameter of 2.soc_create: The Cmnet account number is 10,cmwap 14 by default. There's nothing wrong with the simulator. As long as the PC can surf the internet.
3.soc_setsockopt Soc_nbio setting does not block
4.soc_setsockopt Soc_async Setting Async
5.soc_connect,soc_write,soc_read return Soc_wouldblock must wait for 1 of the notification function to be processed. It is best to set the timeout to close the socket.
6. Convert any pointer of data into Short,int
ARM features, the short pointer must be 2 aligned, and the int pointer must be 4 aligned.
Compact data from the network (packed), must support any address conversion to short or 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;
}
HTTP protocol emulation for 7.CMWAP
Cmwap must be proxied via 10.0.0.172:80 port
Go to the HTTP protocol. Typically 1.1
#define Proxyhttprequestheader "post/http/1.1\r\n" "x-online-host:www.abc.com:12345\r\n" "keep-alive:close\r\n" "Content-length:%d\r\n" "\ r \ n"
X-online-host is followed by the target machine network address and port
Content-length the following data length
After the head is followed by the data, it is best to use Base64 encoding.
Server-side received data is generally modified by the mobile gateway.
HTTP emulation for 8.cmwap: server-side return format:
#define Http_response_header "http/1.1 ok\r\n" "Content-length:%d\r\n" "\ r \ n"//Content-length after filling in the subsequent data length
After the head is followed by the data, it is best to use Base64 encoding.