P2P streaming program

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 30
Reputation: Hannahlv is an unknown quantity at this point 
Solved Threads: 0
Hannahlv Hannahlv is offline Offline
Light Poster

P2P streaming program

 
0
  #1
Sep 16th, 2008
Hi, everyone!
I'm doing a p2p streaming project. This project is actually about : the server and client will connect first (socket created), after connect then client will receive the IP address of another client from server, then those 2 clients connect together and start streaming.
I can write the program that let server and client connect, but p2p I don't know how to do.
1. In 1 program can create 2 sockets?
2. Hope you can help me with a sample code of p2p, connect and/or streaming. I already do a search on Google but only see server-client version (this kind of thing I can do).

Thanks a lot for your help and your time.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: P2P streaming program

 
0
  #2
Sep 16th, 2008
Like for example, getting the source code for existing p2p clients?

"p2p" isn't magic. It's just a pair of sockets (usually) and an understanding of the protocol (usually the hard part) of sending and receiving the right information, and knowing what to do with it.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: P2P streaming program

 
0
  #3
Sep 16th, 2008
Let one (anyone) client is appointed "p2p server" and another client is appointed "p2p client" by the server.
I can write the program that let server and client connect
That's all - you know the right solution. After p2p connection establishing they will have only p2p protocol troubles as was mentioned by Salem...
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 30
Reputation: Hannahlv is an unknown quantity at this point 
Solved Threads: 0
Hannahlv Hannahlv is offline Offline
Light Poster

Re: P2P streaming program

 
0
  #4
Sep 16th, 2008
Yes...I understand what you all say, but the thing I'm not very clear is, how they decide who will be server and who will be client. Like the server-client version, the server must do SOCKET,BIND, LISTEN, ACCEPT,CONNECT, but client need to CONNECT only. (I'm using TCP). Now the client-client version, one can be server to another one, and can be client to another one also. So...how can I write the code for it? Think that there's another way to do, where peer just send data to another peer through the socket. I'm not sure how to implement. Can you suggest any method for me, or any sample? Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: P2P streaming program

 
0
  #5
Sep 17th, 2008
There is no "server" or "client", that's why it's called "peer" to "peer". They're both equal to each other.

Listen on a port for anyone who wants to talk to you, and be a "server" to those connections. And attempt to connect to other sites and be a "client".

> So...how can I write the code for it?
The same way that you would for any s/w which has multiple sockets open. Use select() to wait for any activity on any of the open sockets, then deal with any data that arrives, or send any pending data which needs to be sent.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,861
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: P2P streaming program

 
0
  #6
Sep 17th, 2008
I agree with Salem, select() is the way to go. If you want to learn how this function works, look at Beej's guide
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: P2P streaming program

 
0
  #7
Sep 17th, 2008
My suggestion with (quoted!) "p2p server" and "p2p client" was retlated to peer-to-peer connection stage: it's a common way to go in brokered P2P systems (one peers connects to another with server supported mutual seacrh stage). Client and server are roles, not only fixed application architectures. Look at the original post: the author has a code to establish TCP connection. OK, it's possible to reuse this code for p2p connection.

After that peers have dual TCP channel - it's enough for peer-to-peer communications. It's the other story what's data exchange protocol used. May be they will establish another links, will start another processes or threads...
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 30
Reputation: Hannahlv is an unknown quantity at this point 
Solved Threads: 0
Hannahlv Hannahlv is offline Offline
Light Poster

Re: P2P streaming program

 
0
  #8
Sep 17th, 2008
Well... Thanks for help from you all. I will try select(). I'm quite new to this p2p concept, that's why I got confused with server and client.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC