void spike_to_net(spike_net_t *spike, Trode *t){ if(true){ char buff[4000]; int buff_size; spikeToBuff(spike, buff, &buff_size, true); if(false){ printf("buffsize: %d\n",buff_size); for(int n = 0; n < buff_size; n++) printf("%c",buff[n]); printf("\n"); } //printf("name %d ip %s port %d sockfd %d \n",t->name, t->my_netcomdat.host_ip, t->my_netcomdat.port, t->my_netcomdat.sockfd); if(false){ printf("name %d sockfd %d\n", t->name, t->my_netcomdat.sockfd); fflush(stdout); } NetCom::txBuff(t->my_netcomdat, buff, buff_size); } if(false){ NetCom::txSpike(t->my_netcomdat, spike); } }
int NetCom::txSpike(NetComDat net, spike_net_t *spike){ char spike_buff[MAX_SPIKE_NET_BUFF_SIZE]; int spike_buff_size; spikeToBuff(spike, spike_buff, &spike_buff_size, true); sendto( net.sockfd, spike_buff, spike_buff_size, 0, (sockaddr*) &(net.addr_in), sizeof( net.addr_in) ); return 0; }
void spike_to_disk(spike_net_t *spike){ char buff[4000]; // TODO: get the right buffer size int buff_size, n; // TODO: Get this part thread-safe, needz mutex spikeToBuff(spike, buff, &buff_size, false); if(arte_disk_on){ pthread_mutex_lock(&main_file_mutex); try_fwrite <char> (buff, buff_size, main_file); pthread_mutex_unlock(&main_file_mutex); } }