File
176981636253.jpg
- (369.85KB
, 1024x768
, Green Sea Turtle.jpg
)
/* gcc -pthread telserve_*.c */
#include "telserv/globals.h"
#include "telserv/connect.h"
int main(int argc, char *argv[]){
int c;
int read_size;
server.sockID = socket(AF_INET, SOCK_STREAM, 0);
if(server.sockID < 0){
perror("Socket Failure");
}
else{
perror("Socket Creation");
}
server.address.sin_family = AF_INET;
server.address.sin_addr.s_addr = INADDR_ANY;
server.address.sin_port = htons(PORT);
if(bind(server.sockID, (struct sockaddr *) &server.address, sizeof(server.address)) < 0){
perror("Bind Failed");
}
else{
perror("Bind Socket");
}
for(client_cnt = 0; client_cnt < MAX_USERS; client_cnt++){
if(listen(server.sockID, 3) < 0){
perror("Failure to listen");
}
else{
printf("Server listening on port %d\n", PORT);
}
c = sizeof(struct sockaddr_in);
if(player[client_cnt].client.sockID = accept(server.sockID, (struct sockaddr *) &player[client_cnt].client.address, (socklen_t*)&c)){
puts("Connection Accepted");
pthread_create(&player[client_cnt].client.thread_id, NULL, connection_handler, (void*) &player[client_cnt].client.sockID);
/*pthread_join(client[client_cnt].thread_id, NULL);*/
puts("Handler assigned");
}
}
return 0;
}
Digging through some old projects and found this experiment I was working on. I think the idea was a p2p network from scratch. User data, messages, etc would be prepped into an xml file and shared accross contacts. By including mutual contexts in the requested xml the network could be self sustaining and eliminate the need for central company host or tracker. I have some handwritten notes here somewhere..
It's basically the concept behind distributed hash tables I think.
1
post
omitted. Click Reply to view.