2

I'm new to Java, and I wanted to do something cool with it. I came up with the idea to set up a local server for my home with it as the first step. I want a simple server running without internet, which all the devices connected to my home wifi can view.
On a later stage, I'm planning to do various stuff with it, like for starters a simple chat application. Or a portal for sharing files between my devices.
And in the end product, I want to do streaming. Like the host plays a music on the server and all the connected devices can go to the page and listen to the same music completely synced. Or stream a video!

It's just an idea for the moment, I know this kind of stuff may take a lot of research work, but being new I'm really confused where to start. I just need suggestions/guidance if what I'm saying is possible, and what can I do to get to where I want.

Thanks in advance! :)

Aakash Choubey
  • 426
  • 3
  • 19
  • You may come to find there are [certain tools better suited for web servers](http://flask.pocoo.org/). With all respect, it may just become discouraging to tackle some of those problems with pure Java. – rob Nov 03 '17 at 21:49

4 Answers4

3

It's a long journey if you are building from scratch. There a lot of API which you can use to achieve this very easily. But, I am just going to explain you from very basics and then you can go forward and do more research.

enter image description here

There are 3 main concepts to achieve what you are saying:

  1. Clients: Things which sends request to a server. The devices like mobile, laptop etc.
  2. Server: Thing which receives the request from client and do some processing and return the result back. Now in real life server is just a software program (can be written in many languages Java is one of them) which runs on a computer and listen for clients request on a ip address + port (ip + port is like an address for server). This is same as if I want to send a letter to you I should know your address.
  3. Socket Programming: Socket programming defines protocol and mechanism through which client and server can communicate. In above image all the links are made using socket programming. Thread in above image allow concurrency so for above image every client is like a thread for server.

In your case because you want to connect your client to server through wifi. Your architecture would look like this.

Client                
Client    -------------------   WIFI  ----------------  SERVER
:
:

Where WIFI is just forwarding your request to server and response from server to your client.

Now as you want to achieve different things like chat application and live streaming.

Chat Application (https://www.codeproject.com/Articles/524120/A-Java-Chat-Application)

  1. For chat application we have to make sure that the message which we have sent must reach the destination.
  2. To allow this 100 % accuracy socket programming provides you with TCP protocol.

Streaming Application {Audio/Video} (Live audio stream java)

  1. For streaming application TCP protocol is not neccessary because of two reason.
  2. Firstly, we actually are ok that if one or two packet are lost hence you can see when using youtube there are some glitches.
  3. For online streaming most important thing is it should be fast and TCP is a very heavy protocol.
  4. Thats why Socket Programming also allow you to use UDP protocol which is faster then TCP but don't provide the guarantee that message will reach.

Above is a very brief introduction in laymen term. For better understanding you have to read about Socket Programming. Once, you did that you can do above project. However, if you see above link you can do your project but you won't understand anything and more importantly in case of failure you can troubleshoot.

Arjun Chaudhary
  • 2,373
  • 2
  • 19
  • 36
2

That's a nice project to work on. You'll be learning a lot.

Maybe one simple thing you could do as a start is to set up a server to broadcast information using a web socket.

You can find a lot more on internet, but here are some examples:

http://www.baeldung.com/java-websockets http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html

I don't know if it performs well broadcasting data, but I've been working on a chat application and for simple messages it does the job really well.

1

Of course you can do what you are thinking, however as you said it yourself it will take alot of RnD to complete things up.

I'll suggest you the way to start would be first to identify and divide your work into different modules for e.g. (File sharing, chat, Music store, etc.)

Then for each of the modules create small use-cases e.g. FOR File sharing :

  • display a directory contents
  • switch directory
  • create directory
  • download file

.....and so on.

I assumed you have knowledge of programming and web applications :p

Start development work only after above uses cases are complete. Begin with taking one use-case at a time e.g.

display a directory contents

create a servlet/jsp for that deploy that and then go on with next one untill you complete all the usecases and modules.

0

That is an VERY ambitious project for someone new to Java. I'd recommend you don't start with a server first, especially a streaming one. Start with basic things, learn about datatypes, classes and object, data structures, collections, things like that. Learn to use the debugger, cannot stress the importance of that one enough. Once you feel comfortable with those concepts, then you move onto servers. By then you'll have a much better grasp on the language and most importantly will understand what Java is telling you when you are looking at a stack trace.

SergeyB
  • 9,478
  • 4
  • 33
  • 47
  • Thanks for the suggestion. I'm new to Java but I have experience with C++. So grasping basic OOPs concepts was easy. I'm done through the basics, I believe. – Aakash Choubey Nov 03 '17 at 03:55