活到老学到老,难倒好汉的往往都是些小技巧。小弟发点小小心得,没准有兄弟有用。
基本的东西不多废话了,例程里很清楚。
Send/receive等动作依靠tp_id和conv_id来继承从initialize和allocate获得的值。
一.异步方式一般流程:
异步方式比较简单,跟TCPIP一样,每次会话都来一次connect/close,APPC每次都allocate/dealloate一次。
多次异步流程:
initialize();
for(){
allocate();
send()/receive();
receive()/send();
deallocate();
}
terminate();
二.同步方式的两个参数:
要用同步方式,就不能在循环里做allocate,双方send/receive都在一个conv_id里实现,一般流程是:
initialize();
allocate();
for(){
send()/receive();
receive()/send(); /**方式是否变、怎么变要看你对方的程序设计**/
}
deallocate();
terminate();
我的程序用mapped方式,就以mapped对应参数来说。
要正常实现,有两个参数要注意:
1.在allocate时要设置:
mcalloc.sync_level = AP_CONFIRM_SYNC_LEVEL;
2.如果需要在receive时通知是否更改通讯状态,由这个设置完成:
mcrec.rtn_status = AP_YES;
起实际作用的是mcrec.rtn_status。定义是否带回对方通讯参数,有了这个参数,通讯层的状态才会自动跟着对方改变。
文档里都写得很清楚,不过,文档里说了一大堆参数,老试验费很多时间,写出来,不用大家费时间了。
三.rtn_status的说明:
Indicates whether status information and data can be returned on the same verb. Possible values are:
AP_YES
Status information, if available, is returned with the last part of a data record.
AP_NO
Status information is not returned with data. After receiving the end of a data record, the local TP must issue another [MC_]RECEIVE verb to obtain the status information.
有份文档不错,说得很详细:
http://www.dataconnection.com/sna/sxdocs/appcg.htm?./appcg25.htm
[
本帖最后由 skin 于 2006-6-12 23:28 编辑 ]