|
Hello Jim, You wrote: >We have a sockets application on the AS/400 that is talking to a PC based >application running under Windows sockets. Unless you are sending binary data or your PC program can process EBCDIC data you must convert what you send to ASCII. I don't think you are doing this (read on ...) >The customer is getting our data string followed by a bunch of "@" (nulls) >out to the end of the transmission. Now, the Commercial At sign (the "@") is NOT a null. An ASCII @ is x'40' which also happens to be an EBCDIC space hence my thoughts that you are not converting the data. >Our interface is working well, except for one small problem. The >SocketData field that holds the data portion of the packet is defined as a >variable length field and we specify the length (%len) of the data string >on the send function, but no matter what we do, we can't get the program to >send the actual length of data down the line. I suspect that when you fill the varuing length field you don't trim trailing blanks thus they are treated as part of the data and therefore contribute to the value returned by %LEN. If the trailing blanks are not part of the data then use %TRIM when you populate the varying length field. >(In some cases, according to a trace, it's the "Max segment size - 1458, >other times it's the Max data length of our data field - 2048) The >customer only wants to see the actual length of the data comming to him. >He says that's all he sees from everybody else. The amount of data visible in a trace depends on many things. For instance, packets get broken up by TCP and may not reassembled by the tracing tool. Quite simply, The other programs have been written properly and send the correct length while yours does not. The other program are probably written in C and likely use null-terminated strings as an equivalent to RPGs varying length fields. They would then use strlen() to return the number of characters in the field not including the terminating null. Null-terminated fields are NOT required to work with sockets, it is just that C doesn't offer much else. Note that if blanks occur between the last character and the terminating null then those programs will also send the extra characters. >How can we make the Socket Send function only send the data and then stop >sending??? The various send() functions send EXACTLY the amount of data you tell them too. You specify the length as the third parameter on send(). You are telling send() to send all the extra blanks because those blanks are in the varying length field with the data. There is an old adage in the Unix world: "select() is not broken". It means that if a system function is not behaving properly the problem is most likely in your code rather than in the system code. Running debug on your program and inspecting the result of the %len function would highlight the problem. Regards, Simon Coulter. FlyByNight Software AS/400 Technical Specialists Eclipse the competition - run your business on an IBM AS/400. Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ Fax: +61 3 9419 0175 mailto: shc@flybynight.com.au \ / X ASCII Ribbon campaign against HTML E-Mail / \
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.