Code:
recv_numbytes = recvfrom(recvfd, &instruction, sizeof(instruction), 0, (struct sockaddr*)&ocu_addr, &recv_len);
printf("recv = %d\n", recv_numbytes);
//printf("sizeof pw = %d\n", sizeof(pw));
switch(recv_numbytes)
{
case -1: perror("recv got problem");
exit(1);
case sizeof(bcast_msg): {
//printf("This is the bcasting msg\n");
break;
}
This is part of the code (thread) dealing with the broadcast msg. In this process, there's another thread that is broadcasting msg out at the same time. The broadcasting code is:
Code:
while(1)
{
bcast_numbytes = sendto(bcastfd, &bcast_msg, sizeof(bcast_msg), 0, (struct sockaddr*)&bcast_ip, sizeof(bcast_ip));
if(bcast_numbytes == -1)
{
perror("Error in bcasting");
close(bcastfd);
exit(1);
}
The broadcast msg is an integer. Is that a way to prevent the broadcasting msg to be received by the above coding? One last question is that must the port of the client and the server to be the same to establish any form of connection?