Using Visual C# to send unchanged data over TCP socket to AS400 i-series?
-
After googling for a week, I figured I'd ask. Here's a short description of the project. I'm fairly new to Visual C#, and my main experience is in AS400 programming. Basically, I'm needing to build a string of data that has many fields, and many field data types. For example, field 1 might be a length indicator, that is a number in hex. The 2nd field might be an EBCDIC name field. The 3rd could be a hex character value, etc. I cannot for the life of me figure out how to send the data using visual C# to the byte array, unchanged. My design thought process was that I would read through each field, figure out what the data type is, and convert the data in String format. Then I would just add it to the end of the byte array and send the byte array through TCP to the AS400. As an example, I'll just use a field length indicator. On the PC, the length of the field is 22. This should be translated to hex, which is the value of x'16'. So, for this example, I want to take the human number 22, and translate it to hex x'16', and send it to the AS400 as x'16'. I've tried many variations on this line of code: byte[] bytes = System.Text.Encoding.Default.GetBytes(St… No matter what I try, it seems to always make byte 1 = 31 and byte 2 = 36 (ASCII). I just need byte 1 = 16, so the AS400 can understand what the value is. If this works, then field 2 might be "ABC" in human form, but x'FAFBFC' in string form. So byte 1 needs to be "FA", byte 2 needs to be "FB", and byte 3 would need to be "FC". I think I can convert just about anything in a String representation, but getting that data to the AS400 has proven to be quite a challenge. I've gone through several manuals on the subject, but they seem to just mentioned the history of encoding and how to cooks eggs over easy. I've also tried praying, and even that hasn't helped! Anyone have any words of wisdom on how this may be done? Thanks!
-
Answer:
Can't see you code.. add some spaces in or paste on pastebin if every field you want to send over is one byte long then you can define your own byte array: byte[] bytes = new byte[numberOfFields]; bytes[0] = 22;// field length indicator = 00010100 -- just re-read your question - you won't be able to send everything in one byte array a string (more than one char long) is made up of multiple bytes so it would need its own byte array i realise this might not be much help - bit rushed for time. If you repost the code & and example of exactly what your're trying to do i'll take another look and try to come up with something more helpful
Darren at Yahoo! Answers Visit the source
Related Q & A:
- In Visual Studio 2012 or 2013, how can I register a DLL file on Windows 7 64-bit computer using a Custom Action command?Best solution by Stack Overflow
- How do I connect to SQL Server using C#?Best solution by Stack Overflow
- How do I send pictures from my e-mail to my I-Phone?Best solution by ehow.com
- Is there some kind of API for MSN protocol (for using in C# asp.net application?Best solution by Stack Overflow
- Who is using my account to send out spam?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.