| | |
| | | network net; |
| | | } connection_info; |
| | | |
| | | void read_all(int fd, char *buffer, size_t bytes) |
| | | { |
| | | //printf("Want %d\n", bytes); |
| | | size_t n = 0; |
| | | while(n < bytes){ |
| | | int next = read(fd, buffer + n, bytes-n); |
| | | if(next <= 0) error("read failed"); |
| | | n += next; |
| | | } |
| | | } |
| | | |
| | | void write_all(int fd, char *buffer, size_t bytes) |
| | | { |
| | | //printf("Writ %d\n", bytes); |
| | | size_t n = 0; |
| | | while(n < bytes){ |
| | | int next = write(fd, buffer + n, bytes-n); |
| | | if(next <= 0) error("write failed"); |
| | | n += next; |
| | | } |
| | | } |
| | | |
| | | void read_and_add_into(int fd, float *a, int n) |
| | | { |
| | | float *buff = calloc(n, sizeof(float)); |
| | |
| | | //printf("New Connection\n"); |
| | | if(info.counter%100==0){ |
| | | char buff[256]; |
| | | sprintf(buff, "/home/pjreddie/net_%d.part", info.counter); |
| | | sprintf(buff, "unikitty/net_%d.part", info.counter); |
| | | save_network(info.net, buff); |
| | | } |
| | | int fd = info.fd; |
| | |
| | | void server_update(network net) |
| | | { |
| | | int fd = socket_setup(1); |
| | | int counter = 0; |
| | | listen(fd, 10); |
| | | int counter = 18000; |
| | | listen(fd, 64); |
| | | struct sockaddr_in client; /* remote address */ |
| | | socklen_t client_size = sizeof(client); /* length of addresses */ |
| | | time_t t=0; |