The last, but most important, method of the SocketThread class is the void run() method. Add it.
Given the methods we've already created, implementing this method looks very simple.
Let's do it:
1) Request the server address and server port using the getServerAddress() and getServerPort() methods.
Chat (part 17)
- 8
Locked
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Oleh
13 April 2019, 16:01
For all who don't know how to start chatting (on one machine) from IntelliJIDEA.
1. Start server. Right mouse button on the Server class -> run Server.main
2. Enter port to the console. Choose random number from 0 to 65535, the more number is - the more chances to choose free port.
3. Start client the same way. Enter server's address "127.0.0.1" or "localhost" to console (if you running client
on the same machine). At this point you can run Client class on other machine. If you wan't do it, input real
ip address.
3.1 To start second client on the IDEA: Run tab -> Edit configurations -> Client -> Allow parallel run on the
top.
4. Enter chosen server's port.
5. Enter username
6. Enjoy.
+4