简体   繁体   中英

How do you run multiple instances of the same program to simulate multiple clients in eclipse?(Java)

I used the code from this link . It's a simple java client-server chat program. I want to simulate multiple clients connecting to the server in eclipse. So I ran the server, then I ran a client(which successfully connected) but when I try to run additional clients, they say they are connected but the server does not react (ie it should say something like Recieved connection from /127.0.0.1 on port 58864 ).

The weird thing is, I've ran this before and I didn't have any problem then; each client would connect on different port and could communicate with each other. I just don't remember what I did to successfully run multiple clients. In any case, I know the code works but how do you run multiple instances of the same program to simulate multiple clients in eclipse?

Forgot that I edited the code the first time... Basically the try statement of the server was in a while loop to allow multiple connections. Wasted a good 2 hours on this; sad...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM