可变长度的发送和接收命令(从ISeries到.Net) [英] Variable length Send and Receive commands (ISeries to .Net)

查看:41
本文介绍了可变长度的发送和接收命令(从ISeries到.Net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是I系列(AS/400)程序员,我们已经在I系列和GUI Web前端(.net)之间开发了多个套接字程序,这些套接字程序在Send和Receive命令上使用固定长度.我已经在有效的I系列(服务器-客户端)上创建了可变长度的概念证明.我的问题是知道如何帮助我的.net编程朋友创建进行可变长度套接字通信所需的.net代码.您可以帮助解释该怎么做或命令的语法吗?我不确定我使用的是正确的行话吗?谢谢! Scott Nance

I am an I-Series (AS/400) programmer and we have developed multiple socket programs between the I-Series and the GUI web front end (.net) that use a fixed length on the Send and Receive commands. I have created a variable length proof of concept on the I-Series (Server-Client) that works. My problem is knowing how to help my .net programming friends in creating the .net code that is needed to do variable length socket communications. Can you help explain what to do or the syntax for the commands? I''m not sure if I am using the correct jargon? Thanks! Scott Nance

推荐答案

我不确定是否理解正确.您需要为在.net应用程序中使用的命令使用语法,该应用程序通过套接字与I系列的东西(不是很确定这是什么)进行通信.套接字数据报的长度必须恒定,因此所有命令都不应长于该值,对吗?如果是这样,请指定您的朋友将要执行的命令类型.这是某些数据访问(类似查询的命令)应用程序还是某些管理管理应用程序的应用程序?
I''m not sure if understood properly. You need to syntax for commands to use in .net application which communicates with I-Series stuff (not really sure what is this) via sockets. Socket datagram length have to be constant so all the commands shouldn''t be longer than that value, right? If that so, please specify what kind of commands your friends are going to implement. Is this some data access (query-like commands) application or some administration managing app...


我必须不同意helianthus87.套接字数据报的长度不必一定是恒定的,而这就是问题所在.将套接字连接视为流或另一端恰好相距数英里的管道.您需要使用扫描流时可以识别的一些定界符或包含长度字段的标头来打包数据.传输很容易-只需将消息数据与标头或定界符打包并发送即可.套接字实现将在必要时将其切碎成传输单元(甚至将相邻的小块焊接在一起).在接收方,该如何做取决于您在上面选择的选项.对于定界,基本过程是:
I must disagree with helianthus87. Socket datagram lengths do *not* have to be constant, and therein lies the issue. Consider a socket connection to be a stream, or pipe whose other end happens to be miles away. You need to package your data with either some delimiter(s) you can recognise when scanning the stream or a header that includes a length field. Transmission is easy - just package the message data with header or delimiter(s) and send. The socket implementation will take care of chopping it up into transmission units if necessary (or even welding together adjacent little chunks). On the receive side, how to do it depends on which option you chose above. For delimited, the basic process is:
while (data_available(socket))
  {
  read a byte and append to local buffer;
  if it was a end-of-message mark
    process the buffered message;
  }


对于定界的:


For length-delimited:

for (length_of_header)
  read a byte into header buffer;
for (length_of_rest_of_message)
  read a byte into message buffer;
process message;


我的个人偏好是使用长度分隔符,原因有两个:
1.它的数据透明.您不必确保数据流中不包含您选择作为定界符的任何内容.[1]
2.获得标头后,您会发现可以在其中有用的各种其他内容.

干杯,
彼得

[1]许多年前(70年代中期),我为一家主要航空公司从事信息交换工作.他们的电传替换使用撕带消息定界:NNNN =消息结尾,ZCZC =消息开头.在波兰交响乐团进行世界巡回演出之前,这一切都非常出色! :laugh:

[edit]已开始和结束互换.已经有一段时间了... [/edit]

[@ helianthus87]从最初的问题来看,我认为OP具有I系列功能,只需要一些信息即可告诉他的.NET同事.我可以继续讨论阻塞套接字和非阻塞套接字以及各种各样的套接字,但是{my}的寿命太短了. :)

记住投票并接受良好答案.


My personal preference is for length-delimited, for a couple of reasons:
1. It''s data transparent. You don''t have to make sure your data stream doesn''t include whatever you''ve chosen as a delimiter.[1]
2. Once you''ve got a header, you will find all sorts of other things you can usefully put there.

Cheers,
Peter

[1] Many many years ago (mid ''70s) I worked on a message switch for a major airline. Their telex replacement used torn-tape message delimiting: NNNN = end of message, ZCZC = start of message. That all worked brilliantly until the Polish Symphony Orchestra went on a world tour! :laugh:

[edit] had start and end swapped. It''s been a while...[/edit]

[@helianthus87] From the original question, I thought the OP had the I-series side working, and just needed something to tell his .NET colleagues. I could go on about blocking and non-blocking sockets and all sorts of such, but {my} life''s too short. :)

Remember to vote, and accept good answers.


这篇关于可变长度的发送和接收命令(从ISeries到.Net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆