Linux Socket Debug

Source: Internet
Author: User

In the process of debugging the PCIe board driver, a socket is used to communicate between the Web front end and the PCIe board, as a test environment is built. The test is that the Linux system's PC function sends a file to the PCIe board and then receives the file after the PCIe board processing.

The project was left by the former colleague, and there was no handover. The debugging process and the problems that arise are as follows:

(1) Compile the PCIe driver source code.

(2) Load the driver module.

(3) Compile the service (test environment) source code, including socket server.

(4) Run the service and run the socket server.

The service has been added to the system under Linux to view service commands: $ps aux, the command can see the PID number of the service, the status of the operation and other information.

The service contains two child threads, each of which binds to a port. The printing information is added during the debugging process, the first time you run the server, you can see that the socket was created successfully and the binding port succeeds. However, when you run the service again, the server will fail with a port binding and use the command to view that port number:

            

You can see that the port is already occupied by the service that was running earlier, and the PID number of the service is 2568.

At this point, you need to "kill" (Close) the same name before running the service, the command used is:

          

In this case, the compiled service can run normally again. It is important to note that when running the service again, turn off the previous process and release the port.

(5) Compile the client and run it.

Server-side printing after running client: failed to open file. Analyzing the data transmitted by the client side, the client side sends to the server only the file directory rather than the file.

So debugging Linux under the socket to send files, refer to the Web related files, you need to first open the client side file and write to buffer.

However, when the client side to open the file and error, then consider that should be the file directory is not given correctly.

The file directory previously written is: fromfile= "/home/xilinx/test/guangmang-1.ts";

The modified file directory is:fromfile= "/home/lcy/xilinx/test/guangmang-1.ts";

  After modification, the client can open the file correctly. The reason for this problem is that you know too little about Linux.

Back to think of the client side can open the file, then the server side should be able to open the file Ah, so modify the PCIe drive server side file directory format, compile and run (don't forget to close the previous service), run the client, You can see that the server side can open the file correctly.

The debug of the socket is complete.

Linux Socket Debug

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.