Boost: ASIO connection management 6

Source: Internet
Author: User

Start with newlispProgramTest, initiate a connection, send a correct character 'a', connect continuously, then send an error character, disconnect.

The test script is as follows:

(Define (quit-for-error) (println (net-error) (exit) (set 'socket (net-Connect "localhost" 8888 )) (If (net-send socket "A") (println "Send a successfully") (quit-for-error )) (If socket (println (net-send socket "C") (quit-for-error) (Exit)

The newlisp script is explained here:

Quit-for-error is a custom function that prints network error information and exits the program.

For each net-Send request, you must determine the return value. If it is nil, the system exits.

Run:

Newlisp./test_wrong_char.lspsend A successfully1

The service program prints the following results:

./Cppapplication_4 the number of connections is: 1The new connection object is starting now. correct data has edwrong data has ED, char is: 99 closing the socket ~ Connection

Write a multi-threaded script to initiate 10 connections.

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.