I need some help in java related to networking! | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

I need some help in java related to networking!

I am comfortable with java, but a total beginner with networking. I have successfully learned to establish a server and a client, but they seem to work only when they are started on the same PC. I want a server app which would work on my PC and a client which would work on a device connected to the same network.

22nd Nov 2019, 3:56 PM
Anirudh Sharma
Anirudh Sharma - avatar
16 Réponses
+ 1
I would only say one thing. As a student whose test paper contains questions worth 6 marks of writing such programs where you just have to take input 3 numbers and out their sum, all in terminal(no GUI), i am glad to meet such an awesome person...😁
24th Nov 2019, 4:38 PM
Anirudh Sharma
Anirudh Sharma - avatar
0
Sorry if i am wrong, but do we have to port forward, even for private local servers which expects clients connected to the same network? I am pretty sure we have no such port forwarding done, but we still can play games like mini militia, minecraft, dual... Is port forwarding related to my router and ISP or my application-only?
23rd Nov 2019, 2:01 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
Hmm, "to use the devices IP and port"?. Can you please help this noobie along this code: 1): Does it require some editing regarding adding the IPs and ports. Or 2): The code is wrong and i should use some other way. https://code.sololearn.com/c0tq7SSXAL4J/?ref=app https://code.sololearn.com/cZXwGBRTmhWV/?ref=app
23rd Nov 2019, 10:05 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
Am sorry for providing a messy code, but its quiet far from what really i am working on. Please ignore the mess.😅
23rd Nov 2019, 12:29 PM
Anirudh Sharma
Anirudh Sharma - avatar
0
Thanks a lot, but this noob is literally a "noob" in networking. This is totally a new topic for me. I know much about IPs, how to get'em, but how to specify it to the program in code? Any how I have uploaded the project on github (as Minecraftian14). Its a simple, small project. If you wish, you may have a look. But logically, its almost the same thing...
23rd Nov 2019, 6:02 PM
Anirudh Sharma
Anirudh Sharma - avatar
0
Thanks, will report when i get my lappy back!
24th Nov 2019, 2:11 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
As per your prev post, i know networking is a big topic, but not for me. Actually, if one can solve my doubts or there exists good tutorials, i can directly start on a small project. Three days ago, all i knew about networking was internet, router, www.... But now i play with ports and IPs... Thanks a lot, am really happy you spent so much time to answer it.
24th Nov 2019, 2:14 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
As per your prev post, i know networking is a big topic, but not for me. Actually, if one can solve my doubts or there exists good tutorials, i can directly start on a small project. Three days ago, all i knew about networking was internet, router, www.... But now i play with ports and IPs... Thanks a lot, am really happy you spent so much time to answer it.
24th Nov 2019, 2:15 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
Further, one last thing. If i introduce a 0.1s pause to every loop, such as the two threads used for input and output ( in the project i uploaded), will it help? Till now it seems to be saving processing time in situations when something goes wrong.
24th Nov 2019, 2:17 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
You seem to know a lot!! But how do you make a call to retrieve data "every X seconds"?; won't that require Thread.sleep(X*1000);?
24th Nov 2019, 4:38 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
I wanted to use threads because they act as separate process(that's their use in most cases): one for input and the other for output. However if i set input and output in one single loop (whether in thread or not; will have less effect) there comes a moment when the server is sort of deadlocked, while the client is waiting for server's response, we see that's what server was doing- waiting for client's response....
24th Nov 2019, 4:42 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
I have done threads as a part of three chapter in my java course. Only networking was not done.
24th Nov 2019, 4:43 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
OMG! It worked, thanks a lot @「HAPPY TO HELP」. :)
24th Nov 2019, 5:12 AM
Anirudh Sharma
Anirudh Sharma - avatar
0
Hey Prabhat Diwakar, you better post a new question regarding your issue. And do provide proper information related to that.
24th Nov 2019, 3:13 PM
Anirudh Sharma
Anirudh Sharma - avatar
0
Hi, if i have port forwarding enabled on my network, how will i communicate to my application from a different network? I mean what changes i will have to make?
5th Jan 2020, 11:58 AM
Anirudh Sharma
Anirudh Sharma - avatar
- 1
I need help related to java and html plizz help e
24th Nov 2019, 2:12 PM
Prabhat Diwakar
Prabhat Diwakar - avatar