| | |
P2P streaming program
![]() |
•
•
Join Date: Jul 2008
Posts: 30
Reputation:
Solved Threads: 0
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.
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.
Let one (anyone) client is appointed "p2p server" and another client is appointed "p2p client" by the server.
That's all - you know the right solution. After p2p connection establishing they will have only p2p protocol troubles as was mentioned by Salem...
•
•
•
•
I can write the program that let server and client connect
•
•
Join Date: Jul 2008
Posts: 30
Reputation:
Solved Threads: 0
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
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.
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.
I agree with Salem, select() is the way to go. If you want to learn how this function works, look at Beej's guide
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...
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...
![]() |
Similar Threads
- Worm.Win32.NetSky alerts (Viruses, Spyware and other Nasties)
- Something has taken over my PC and I need some help please (Viruses, Spyware and other Nasties)
- Something has taken over my PC (Windows NT / 2000 / XP)
- Another hacktool.rootkit virus (Viruses, Spyware and other Nasties)
- My Personal Horoscope crap... (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Huge int read input & process in C/ C++
- Next Thread: Array of pointers to structure
| Thread Tools | Search this Thread |
#include adobe ansi api array arrays asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork framework frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf scripting segmentationfault sequential socket socketprograming standard string systemcall testing threads turboc unix user voidmain() wab windows.h windowsapi






