Introduction to DICOM network communication (1)

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/assassinx/p/3649103.html

Look at the standard more and more paste, the root cause: Dicom abstraction is very serious, is "expert" to get. No way.

What is the service class is what SOP, I believe you see the DICOM standard head most do not know how to start. It's not the socket, it's hard. First you have to understand that God is called PDU, from the PDU, I can only say so. PDU is the PDU protocol data unit anyway, that's the concept. You can understand it as a socket packet. His structure is start 1 bytes is the PDU type then a byte is always 0, then 4 bytes represents the data length and then the specified length of the data.

Diagrams:

And then, specifically, to write this blog, I got some test data, all binary files.

Okay, and then we're going to design a program right away:

1 namespaceDcmecho2 {3     class Program4     {5         Static voidMain (string[] args)6         {7TcpClient client =NewTcpClient ();8Client. Connect ("localhost",104);9NetworkStream stream=client. GetStream ();Ten  One             byte[] data = Dump (0); A             byte[] Data_res =New byte[1024x768]; -             UINTLen =0; -Stream. Write (data,0, data. Length); theStream. Read (Data_res,0,2); -Stream. Read (Data_res,0,4); -             //Note here is the big byte order to be flipped -Array.reverse (Data_res,0,4); +Len = Bitconverter.touint32 (Data_res,0); -Stream. Read (Data_res,0, (int) len); +  Adata = Dump (1); atStream. Write (data,0, data. Length); -Stream. Read (Data_res,0,2); -Stream. Read (Data_res,0,4); -Array.reverse (Data_res,0,4); -Len = Bitconverter.touint32 (Data_res,0); -Stream. Read (Data_res,0, (int) len); in  -data = Dump (2); toStream. Write (data,0, data. Length); +  - Console.readkey (); the         } *  $         Static byte[] Dump (intindx)Panax Notoginseng         { -             string[] Datas =New string[3]; thedatas[0] =@"The 6D of the above-xx-xx- CC -xx-XX + 6E ------XX A  The xx-xx, XX, and XX the  xx xx, XX, and xx. xx + at xx xx, xx, xx, 2E - 2E 2E, 2E, 2E to 2E $ 2E, 2E , XX, XX, $ 2E 2E (+ 2E)-2E to 2E - Each of the 2E, 2E and 2E - 2E to 2E ----XX the ( 1E) 2E 2E + + 2E - 2E, 2E, 2E , and more.Wuyi The 0B of the most of the 4D the  About - "; Wudatas[1] =@"4 A , XX, xx (xx), XX -  at the xx (xx) xx xx About 2E 2E (+ 2E)-2E to 2E $  to the xx, XX (xx) - At the Geneva -xx-XX, XX - "; -datas[2] =@" at the xx xx, xx xx"; A  +DATAS[INDX] = Datas[indx]. Trim (). Replace (" ",""); theDATAS[INDX] = Datas[indx]. Replace ("\ n",""); -DATAS[INDX] = Datas[indx]. Replace ("\ r",""); $  the             byte[] data =New byte[Datas[indx]. Length/2]; the              for(inti =0; I < data. Length; i++) the             { theData[i] = (byte) Convert.ToInt32 (Datas[indx]. Substring (i *2,2), -); -             } in             returndata; the         } the     } About}
View Code

OK let's test, we always use this program to test: http://www.mrxstudio.com/is also written by me.
Here, the Echo response test was successful:

Understand this, and then, you can not every time others come to put this piece of crap the same thing to someone else, the parameters are not the same as the various instances of the request UID DIMSE command and data are different, will not error? This is the DICOM protocol program is not a common socket program, although are based on the socket. Understand what you're going to do, frankly, no technical content. But it's a pretty big project and it's going to cautious slowly. This is the entire flowchart from the negotiated connection to the process of printing completion:

Introduction to DICOM network communication (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.