Jump to content
xisto Community
Sign in to follow this  
PureHeart

Peer2peer Sharing With VB.NET - How To ? HELP

Recommended Posts

I want to know how a p2p connection work. I want to make somekind of communication in my next application/program. I'm new to networking programming. Please help tell me in detail. I'm currently using VB.NET for it. I still don't know how to connect yet. Is there any free+opensource+popular library that support transfer data via network. I need it. Please reply this with any resouce that you know.Thanks in advance.

Edited by miCRoSCoPiC^eaRthLinG (see edit history)

Share this post


Link to post
Share on other sites

well for any p2p work, u need socket programming. Since I use Classic VB 6.0, I use the MSWINSCK.OCX control for data transfer. In your case you can also use MSWINSCK.OCX with VB.NET, but its suggested to use the inbuilt classes with .NET.You must learn how to estabilish connections with peers. I will give u an example with VB, and usually its similar for all other languages including C on Linux.Start two projects, as the two peers. I will now explain with one project. Create two MSWINSOCK controls on your form. Call one Server and other Client. In the properties box of both these controls, enter index as 0. This will make these control arrays.We need to program the Server control to recieve connections. Set a LocalPort (to something unique say 12345) on the server control and call the ".Listen" method. This will set the server on listen mode. Now whenever a connection is made, the ConnectionRequest Event is fired on the control.The function will look somewhat as follows:Private Sub Server_ConnectionRequest(Index as Integer, ConnectionID as Long) Load Server(Server.UBound + 1) Server(Server.UBound).Accept ConnectionIDEnd SubThis will redirect all incomming connections to an instance of Server. You will need to do protocol programming at the DataArrival event.Now for the Client control, its the simplest of all.You need to simply call this from any master function. Client(i).Connect <ip address>, <port number>Since we kept the port number as 12345, we will use that. 'i' is any array number. 'i' will depend on number of client instances you want.If you have understood till now, then its great and i will help you further. But incase things went over ur head, you must pick up a good programming book and learn socket programming. For VB.NET, the MSDN will do.This was all basic stuff, the main issue in P2P comes when you write the P2P protocol. The best way to write a P2P protocol is to base it on the FTP protocol. If you do that, then the best thing is you can skip the client part, since MS provides MSINET.OCX control which contains a FTP client.As things get advanced, you see that there are P2P techniques like segmentation. That is one segment of a file is downloaded from one user and the other from other user. In this case you need to define a totally original protocol, that will have the "Resume" support. You can although base it on the FTP protocol ofcourse, but the MSINET advantage is lost, since MSINET is not programmed to RESUME transfers. Why I have been emphasising on using FTP as base is since there is a lot of reference material available on the internet. You can even find dozens of working FTP code samples. But yes, most are just client examples. You will need to create the server yourself, which is not a big deal considering you have learned programming properly. You can find the FTP RFC and use it as a reference.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.