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.