FreeCalypso > hg > freecalypso-sw
comparison rvinterf/lowlevel/localsock.c @ 185:ec040f521cc2
rvinterf works after fixing max_fd
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 24 Nov 2013 20:27:21 +0000 |
parents | 7ab6b29e76bb |
children | f5f8776f7c66 |
comparison
equal
deleted
inserted
replaced
184:4714fdfca39c | 185:ec040f521cc2 |
---|---|
95 rc = accept(listener, (struct sockaddr *) &un_addr, &len); | 95 rc = accept(listener, (struct sockaddr *) &un_addr, &len); |
96 if (rc < 0) { | 96 if (rc < 0) { |
97 perror("rvinterf: accept"); | 97 perror("rvinterf: accept"); |
98 exit(1); | 98 exit(1); |
99 } | 99 } |
100 if (rc > max_fd) | |
101 max_fd = rc; | |
100 newcli = malloc(sizeof(struct client)); | 102 newcli = malloc(sizeof(struct client)); |
101 if (!newcli) { | 103 if (!newcli) { |
102 perror("rvinterf: malloc for new client"); | 104 perror("rvinterf: malloc for new client"); |
103 exit(1); | 105 exit(1); |
104 } | 106 } |
105 bzero(newcli, sizeof(struct client)); | 107 bzero(newcli, sizeof(struct client)); |
106 newcli->fd = rc; | 108 newcli->fd = rc; |
107 newcli->next = client_head; | 109 newcli->next = client_head; |
108 client_head = newcli; | 110 client_head = newcli; |
109 prep_for_length_rx(newcli); | 111 prep_for_length_rx(newcli); |
112 output_line("*** Client program connected"); | |
110 return(0); | 113 return(0); |
111 } | 114 } |
112 | 115 |
113 send_local_msg_to_client(cli, msg) | 116 send_local_msg_to_client(cli, msg) |
114 struct client *cli; | 117 struct client *cli; |
133 int cc; | 136 int cc; |
134 | 137 |
135 cc = read(cli->fd, cli->rx_ptr, cli->rx_left); | 138 cc = read(cli->fd, cli->rx_ptr, cli->rx_left); |
136 if (cc <= 0) { | 139 if (cc <= 0) { |
137 /* normal client exit condition */ | 140 /* normal client exit condition */ |
141 output_line("*** Client program disconnected"); | |
138 close_socket: cli->rx_state = 2; | 142 close_socket: cli->rx_state = 2; |
139 return; | 143 return; |
140 } | 144 } |
141 cli->rx_ptr += cc; | 145 cli->rx_ptr += cc; |
142 cli->rx_left -= cc; | 146 cli->rx_left -= cc; |