J
Jack
Hi c++ guru's
I need your help. I have 4 machines and I need them to be able to
communicate to each other via peer to peer architecture. I know that
when we have two machines one machine acts as a client and the other
one as a server. the server machine just listens for incoming
connections. My question is if we have 4 machines do I need to create
3 seperate connections codes and connection sockets on each machine.
for instance if we have two machines, the client has a code similar to
this:
socketChannel.sin_family = AF_INET;
socketChannel.sin_port = htons(PORT);
inet_pton(AF_INET, serverIP, &socketChannel.sin_addr); //PUT THE IP
ADDRESS OF THE SERVER TO CONNECT
sd = socket (AF_INET, SOCK_STREAM, 0);
connect (sd, (struct sockaddr*) &socketChannel, sizeof(struct
sockaddr);
If I have 4 machines, will I need 3 more of these ie. 3 instances of
socketChannel, and sd plus another one of when each machine is a
server (in peer to peer, a machine is both a client and a server) and
basically 4 copies of this same code?
Thanks
I need your help. I have 4 machines and I need them to be able to
communicate to each other via peer to peer architecture. I know that
when we have two machines one machine acts as a client and the other
one as a server. the server machine just listens for incoming
connections. My question is if we have 4 machines do I need to create
3 seperate connections codes and connection sockets on each machine.
for instance if we have two machines, the client has a code similar to
this:
socketChannel.sin_family = AF_INET;
socketChannel.sin_port = htons(PORT);
inet_pton(AF_INET, serverIP, &socketChannel.sin_addr); //PUT THE IP
ADDRESS OF THE SERVER TO CONNECT
sd = socket (AF_INET, SOCK_STREAM, 0);
connect (sd, (struct sockaddr*) &socketChannel, sizeof(struct
sockaddr);
If I have 4 machines, will I need 3 more of these ie. 3 instances of
socketChannel, and sd plus another one of when each machine is a
server (in peer to peer, a machine is both a client and a server) and
basically 4 copies of this same code?
Thanks