-
November 18th, 2008, 03:30 AM
#1
distributed computing c++
hello ppl
i want help regarding distributed computing.
the problem is :
i have to create a client server network. multiple clients multiple servers.
client will ask for different files and the servers will find that file and should give it back to the client.
i have to divide a txt file into different packets and keep it on different servers.
the help i need is :
how to create tcp packets of txt files? so that i can keep them at different servers..
I HAVE TO DESIGN IT IN C++ ..
PLEASE HELP ASAP..
-
November 18th, 2008, 07:49 AM
#2
Re: distributed computing c++
-
November 18th, 2008, 12:23 PM
#3
Re: distributed computing c++
Which part of the project do you need help on? The use of sockets for communication over a network? (If so, use Beej's guide as mentioned by CodePlug) The implementation and architecture for distributed computing? (If so, use a pre-packaged product like BOINC, boinc.berkeley.edu/ )
Mike
Last edited by MikeAThon; November 18th, 2008 at 01:53 PM.
Reason: to correct typo
-
November 20th, 2008, 05:14 AM
#4
Re: distributed computing c++
thank you..i 'll check it and see what can i do..
-
November 20th, 2008, 05:15 AM
#5
Re: distributed computing c++
I need help in Creating Packets of Txt Files.. to save them on different servers..
-
November 20th, 2008, 12:59 PM
#6
Re: distributed computing c++
Post the code that you have so far, and tell us the difficulties that you are encountering with it.
Mike
-
November 21st, 2008, 04:55 AM
#7
Re: distributed computing c++
this is the code i have for the Client Server Chat with Multi-Threading.. this is the SERVER code.
I have to make it change so that i can be able to DIVIDE A TXT FILE INTO PACKETS, THEN SEND THEM TO DIFFERENT SERVERS.. SO THAT WHEN A CLIENT ACCESSES THEM , THEN ALL THE PACKETS SHOULD COME TO HIM.. ITS JUST LIKE P2P FILE SHARING..BUT THE DIFFERENCT IS THAT THIS IS DISTRIBUTED COMPUTING..
HOPE YOU UNDERSTAND.. I NEED SERIOUS HELP.. YOU CAN ALSO CHANGE THE CODE AND SEND IT TO ME..
ONE MORE QUESTION:
CAN I GET THE CODE OF P2P FILE SHARING.. IN C++.. {It should work so that i can understand what actually happens "}
*****************************************************************
#include <iostream>
#include <conio.h>
#include <winsock2.h>
#include <string>
#include <pthread.h>
#include <stdio.h>
#include <fstream>
int getpeername(int sockfd, struct sockaddr *addr, int *addrlen);
using namespace std;
char* buf=new char[50];
char*Buffer = new char[50];
SOCKET comm_sock;
void* func1(void*) {
while(1>0)
{
recv(comm_sock, Buffer, 50, 0);
cout<<"from client: "<<Buffer;
cout<<"\n";
}
}
void* func2(void*) {
ifstream fin;
fin.open("1.txt");
while(1>0)
{
cout<<"\nServer\n : ";
cin.getline(buf,50);
send(comm_sock, buf, strlen(buf)+1, 0);
cout<<"\n";
}
}
void main(int argc, char *argv[])
{
pthread_attr_t attr;
pthread_attr_init(&attr);
WSADATA wsadat;
WORD rVersion;
rVersion = MAKEWORD(2,0);
if(WSAStartup(rVersion, &wsadat) != NO_ERROR)
{
cout<<"WSA initialization failed.\n";
WSACleanup();
return;
}
//Creating the welcome socket
SOCKET welcome_socket;
welcome_socket = socket(AF_INET, SOCK_STREAM, 0);
if(welcome_socket == INVALID_SOCKET)//same as this
{
cout<<"Socket could not be created.\n";
WSACleanup();
return;
}
string ipaddress;
int portno;
//cout<<"Enter your IP address: ";
ipaddress= "127.0.0.1";
cout<< "IP IS : "<<ipaddress<<endl;
// cin>>ipaddress;
//cout<<"Enter the port no.: ";//// mostly gave port number above 5000 ////
portno=6789;
cout<<"PORT : "<<portno<<endl;
SOCKADDR_IN sockaddress;
sockaddress.sin_addr.s_addr = inet_addr(ipaddress.c_str());// use at is it always
sockaddress.sin_port = htons(portno);
sockaddress.sin_family = AF_INET;
if(bind(welcome_socket, (SOCKADDR*)(&sockaddress),sizeof(sockaddress)) == SOCKET_ERROR)
{
cout<<"Attempt to bind failed.\n";
WSACleanup();
return;
}
//listen for incoming connection requests on the welcome socket
listen(welcome_socket, 1);
//create a socket for communication by accepting any requests on welcome socket
//SOCKET comm_sock;
SOCKADDR_IN clientaddr;
int addresslen = sizeof(clientaddr);
// char*Buffer = new char[13];
while(!kbhit())
{
comm_sock = accept(welcome_socket, (SOCKADDR*) &clientaddr, &addresslen);
if(comm_sock != SOCKET_ERROR)
{
cout<<"Connection established with client at: "
<<(int)clientaddr.sin_addr.S_un.S_un_b.s_b1<<"."
<<(int)clientaddr.sin_addr.S_un.S_un_b.s_b2<<"."
<<(int)clientaddr.sin_addr.S_un.S_un_b.s_b3<<"."
<<(int)clientaddr.sin_addr.S_un.S_un_b.s_b4<<endl;
//send and receive data;
//threads
pthread_t tid1,tid2;
pthread_create(&tid1, &attr, func1, NULL);
pthread_create(&tid2, &attr, func2, NULL);
pthread_join(tid2, NULL);
pthread_join(tid1, NULL);
}
}
WSACleanup();
return;
}
*****************************************************************
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|