如何为iso 8583编码数据以传输套接字c#
我不明白如何通过 c# socket.send( byte[]) 发送数据, 我的意思是他们说我需要发送 0800(网络管理请求)进行回显测试,如何转换。 我已经编程了一段时间了,但我不明白这些说明。
谢谢
I don't understand exactly how to send data over c# socket.send( byte[]),
I mean they say I need to send 0800 (Network Management Request) for an echo test, how to convert.
Please I've been programming for a while but I don't understand the instructions.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,您需要了解 ISO8583 消息格式。对于回声测试消息,在 87 版本中,您的 MTID 应为 0800,字段 70(网络管理信息代码)应设置为 301,表示回声测试。
构建 ISO 消息非常棘手。 (无耻插件即将出现)我已经发布了OpenIso8583.Net, .Net 的消息解析器/生成器,可以扩展到您正在使用的 ISO 的特定风格
First of all you need to have an understanding of the ISO8583 message format. For echo test messages, in the 87 revision, your MTID should be 0800 and field 70, the Network Management Information code, should be set to 301, indicating echo test.
Building an ISO message is quite tricky. (shameless plug coming up) I have released OpenIso8583.Net, a message parser/builder for .Net which can be extended into the particular flavor of ISO you are using
您应该首先了解您正在工作的规范;我希望您有比裸 ISO8583 消息规范更具体的内容,即特定于所需字段和内容的内容。重要的是您基于指定存在哪些字段的位图来构建和解封来自消息的 ISO8583 字段的方式。
当我过去用 C# 构建 ISO8583 测试客户端时,我首先将一组可以构建和解除阻塞消息位图的类放在一起。一旦你有了这些,你需要一些代码来构建和解锁你的消息。这些将设置(或测试)位图中的位,然后将预期字段提取或插入到字节缓冲区中。
一旦你完成了这个工作,字节缓冲区消息的实际发送和接收就很简单了。
You should first understand the spec that you're working to; I expect you have something more specific than the bare ISO8583 message spec, something that is specific about the fields required and the content. The important thing is the way you build and deblock the ISO8583 fields from to and from the message based on the bitmap that specifies which fields are present.
When I've built ISO8583 test clients in C# in the past I first put together a set of classes that could build and deblock a message bitmap. Once you have that you need some code to build and deblock your messages. These will set (or test) bits in the bitmap and then extract or insert the expected fields into a byte buffer.
Once you have this working the actual sending and receiving of the byte buffer messages is trivial.
查看规范,不可能在这里提供完整的答案 - 但为了让您开始,您基本上需要创建各种消息并将它们发送到管道中。由于 Socket 类需要字节数组而不是字符串,因此您可以使用 Encoding 类之一来获取字符串的原始字节。如果我正确地从 Wikipedia 阅读信息:
免责声明:我从未必须实施 ISO 8583 并且我查看的参考资料并不清楚这些代码是否实际上是简单的 ASCII 字符(尽管我打赌它们是)。希望更熟悉该标准的人能够澄清或确认该假设。
Looking at the spec, it would be impossible to provide a full answer here - but to get you started, you basically need to create the various messages and send them down the pipe. As the Socket class requires an array of bytes rather than a string, you can use one of the Encoding classes to get at the raw bytes of a string. If I am reading the info correctly from Wikipedia:
Disclaimer: I have never had to implement ISO 8583 and the reference I looked at wasn't clear if the codes were in fact simple ASCII characters (though I am betting they are). Hopefully someone more familiar with the standard will clarify or confirm that assumption.
关于解析器,请在 iso 8583(最好是 2003)上进行一些谷歌搜索
about the parser, do some google on iso 8583, preferably of 2003