There are many ways to communicate with BBB such as TCP/ UDP, USB, UART, I chose UDP to be my main communication method for its simplicity and speed. UDP libraries are already in GCC, allI have to do is to implement the libraries.
You just have to put the data pointer, number of bytes to be sent and destination IP address, the data will be sent from BBB to PC.
size_t udpTXClient(const void *bData, int nSize, char *IP){
struct sockaddr_in serv_addr;
int sockfd, i, servLen;
size_t nTxLen;
size_t nWriteLen;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0))==-1)
err("socket");
servLen = sizeof(serv_addr);
bzero(&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(IP);
serv_addr.sin_port = htons(1111);
//printf("UDP sender enabled\r\n") ;
if((nTxLen = sendto(sockfd, (void *)bData, nSize, 0, (struct sockaddr *) &serv_addr, servLen))==-1)
printf("UDP TX client fail\r\n");
close(sockfd);
return nTxLen;
}



