wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes How to create peer to peer Connection in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "How to create peer to peer Connection in java?" Watch "How to create peer to peer Connection in java?" New topic
Author

How to create peer to peer Connection in java?

Sanchit Gupta
Greenhorn

Joined: Oct 22, 2013
Posts: 4
I want to create voice classrooms in java , it needs to make a peer to peer connection. Still i am using Socket Programming (TCP/IP) but its very time taking,
I can use UDP because we can not the IP of client .

So which connection i can create in java to send voice data to create voice classrooms over the WAN.
Shed Ansari
Greenhorn

Joined: Oct 22, 2013
Posts: 3

If you want run your application over WAN then TCP/IP is not sufficient. I think you have to use UDP protocol.
Shed Ansari
Greenhorn

Joined: Oct 22, 2013
Posts: 3

You can use JXTA protocol for peer to peer connection
Sanchit Gupta
Greenhorn

Joined: Oct 22, 2013
Posts: 4
Can you give me any tutorial or example code to implement JXTA Protpcol ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
If I understand the problem correctly, then what you have in place is built on sockets but it too slow. The first thing to note is that all other peer-to-peer approaches also use sockets, so if that's the cause of the slowness then you're out of luck. But we don't know that yet - you should start by measuring which aspect of your solution is (too) slow, and then try to improve those.

Since JXTA was mentioned, that's an XML messaging protocol - it is unlikely to be the right solution for sending voice data, and likely not fast enough, either. If you want to check it out, the Java implementation is at https://jxse.kenai.com/

Another P2P solution is Apache River, the successor to Jini and JavaSpaces, but it too is built for RPC, so probably not the right solution.

My gut feeling is that you need a Java implementation of RTP for this.


Ping & DNS - my free Android networking tools app
Sanchit Gupta
Greenhorn

Joined: Oct 22, 2013
Posts: 4
My Problem is that - I want to create voice broadcasting in java. Since I am using TCP/IP socket to send voice from one client to other. But it is very slow and creating noise in voice transmission.
The architecture is like- client_1(Teacher)---> Server --->Client_2(Student) , just like an online classrooms.

Flow of process ------> whatever client_1(Teacher) speak is captured using TargetDataLine in a buffer of size[10 KB] then buffer is sent to server using socket programming(till now using TCP) then server send that buffer to client_2(Student) , where student can listen the buffer data by writing buffer on SourceDataLine.

Problem--> The module is working properly on LAN (All 3 module in same wired network) , but when we run it over the WAN , at Client_2(Student ) site there is noise in voice received from server.

Please give me the proper solution of this problem.

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
So it is not actually a P2P architecture, it is a client/server architecture.

If this was my problem I would start by investigating *why* there is noise. Is the data transmitted faithfully, meaning, does the exact same data arrive at the listener that is sent by the talker? If yes, I don't see why there would be additional noise. If no, investigate where (and why) the data is altered.
Sanchit Gupta
Greenhorn

Joined: Oct 22, 2013
Posts: 4
I think when packet travel through WAN , some garbage is add.
how can i count total number of packet send and receive , so that i can compare the number of packet send is equals to number of packets received?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
That depends on the specifics of the code (which we don't know), but since you mention SourceDataLine - that has a write method which writes a specific number of bytes. So you can certainly add up the number of bytes written. I would expect something similar to be possible on the receiving end.

It's possible that the number of bytes written and received stays the same, but that the content of those bytes gets corrupted. In that case you have to inspect the bytes themselves, instead of just counting their number.
Shed Ansari
Greenhorn

Joined: Oct 22, 2013
Posts: 3

Please tell me, is that shuttering or noise. because As you explain your problem that you are using TCP/IP and TCP/IP is slow so shuttering will produce defiantly. According to me firstly you should establish a connection using TCP/IP and then send your voice using UDP.
 
Don't get me started about those stupid light bulbs.
 
subject: How to create peer to peer Connection in java?