I made a simple client-server program in c using sockets and now i want to test it ,by simulating many clients connecting to the server at the same time!I wrote a script to execute the client: ./client
20 times but it didn't work for me since it waited for each client to finish.
Also i wrote another program in c ,this time with threads so it could execute each client with system(./client)
and then detach the thread ,but again i had the same problem!
So what is the correct way to implement this?
最简单的解决方案是执行您的shell脚本,但是在./clientk调用之后加上&,这将把它放在后台并立即运行下一个命令
Here's a really simple way to launch a number of clients without waiting for each to complete:
#!/bin/bash
for i in $(seq 0 20)
do
./client &
done
wait
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.