RT
解决方案 »
- 企业短信系统平台的设计(毕业设计)
- 求助 JAVA 软件工程师 一面试题
- 如何搭建java的3D开发环境
- 这个哪有错误啊 ??急!!!
- 怎样获取年,月,日呢?没查到,呵呵
- SimpleTimeZone.getDefault().inDaylightTime(Date d)的参数是何意思
- 请教用Java查看系统的CPU,内存,硬盘的相关情况,
- 请问如何将Sun的浮点数变换成Intel的浮点数?
- 请问如何给一个数组快速赋初值
- 网址:http://www.film888.com/film.asp?id=pengnick绝对的高速电影网站《星光影视网》(赶快注册)
- JProgressBar 无法自动更新是什么原因??
- java打印多个printable
//打开一个针对面向流的连接套接字的可选择通道。
private SocketChannel openSocketChannel() throws IOException { logger.debug(String.format("openning connection " +
"remote %s:%d, local %s:%d",
this.remoteHost, this.remotePort,
this.localAddress == null ? "*" : this.localAddress, this.localPort)); SocketChannel sch = SocketChannel.open(); try {
Socket socket = sch.socket(); if (this.localAddress != null || this.localPort != 0) { logger.trace("local address is not wild card address"); InetSocketAddress local = this.localAddress != null ? new InetSocketAddress(this.localAddress, this.localPort)
: new InetSocketAddress(this.localPort); logger.trace("binding to local address " + local); socket.bind(local); logger.trace("bind local address ok");
} InetSocketAddress remote = new InetSocketAddress(
this.remoteHost, this.remotePort); logger.trace("connecting remote host " + remote); socket.connect(remote, this.connectTimeout); logger.debug(String.format("connected to peer " +
"remote %s, local %s", socket.getInetAddress(), socket.getLocalAddress())); logger.debug("read time out is set to " + this.readTimeout); socket.setSoTimeout(this.readTimeout); } catch (SocketTimeoutException tox) { logger.error(String.format("connecting timed out " +
"remote %s:%d, local %s:%d",
this.remoteHost, this.remotePort,
this.localAddress, this.localPort), tox); throw tox; } finally { if (!sch.isConnected()) { logger.error(String.format("failed to open connection " +
"remote %s:%d, local %s:%d",
this.remoteHost, this.remotePort,
this.localAddress, this.localPort));
try {
logger.debug("close socket channel due to error"); sch.close(); } catch (Exception x) { logger.debug("error when closing socket", x);
}
}
}
return sch;
}
余额查询
服务类型100001,请求无包体,应答有包体。
返回值: 成功 00000
有异常或错误出现 00501
应答包体:
名称 最大长度 格式
执行结果 (2) 0表示正确查询 -1没有查询到该用户 -2其他错误
用户话费余额 (10) 以“元”作单位,包含小数点
注:应答包头中需要返回请求包头中的业务号码(A6)以及交易类型(A4)
例如这个,但是返回的应答包中,会有执行结果和用户的话费余额,
2包体定义
一个数据包总长度不可大于20k,对存在多条返回纪录的业务,一数据包可含多条记录。长度如超过20K,应以多包数据发送。字段长度定长,每字段之间用”TAB键0x09”分隔,每记录之间用“回车键0x0d,0x0a”分隔。
注意:
数据包若无包体,则长度为80,不包含0x1a;
0x09只是字段之间的间隔符,最后一个字段结尾只有0x1a;
0x0d,0x0a只是记录之间间隔符,最后一条记录结尾只有0x1a
例一:
字段1 + 0x09 + 字段2 + 0x09 + 字段3 + 0x1a 结束
例二:
记录1 + 0x0d 0x0a + 记录2 + 0x1a 结束
例三:
记录1字段1 + 0x09 + 记录1字段2 + 0x0d 0x0a + 记录2字段1 + 0x09 + 记录2字段2 + 0x1a 结束而在一个数据包的头5位总是代表整个数据包的长度,因为现在也没法测试,我想知道的是,这个长度会不会包括,0x09这些东西,
按道理说应该是包含的...但是没法测试,所以想叫大家帮我看看,也好安心