943,681 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1666
  • C RSS
Sep 16th, 2008
0

P2P streaming program

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Sep 16th, 2008
0

Re: P2P streaming program

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Sep 16th, 2008
0

Re: P2P streaming program

Let one (anyone) client is appointed "p2p server" and another client is appointed "p2p client" by the server.
Quote ...
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...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Sep 16th, 2008
0

Re: P2P streaming program

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
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008
Sep 17th, 2008
0

Re: P2P streaming program

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Sep 17th, 2008
0

Re: P2P streaming program

I agree with Salem, select() is the way to go. If you want to learn how this function works, look at Beej's guide
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Sep 17th, 2008
0

Re: P2P streaming program

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...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Sep 17th, 2008
0

Re: P2P streaming program

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
Hannahlv is offline Offline
31 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Huge int read input & process in C/ C++
Next Thread in C Forum Timeline: Array of pointers to structure





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC