172 (void) close(sock);
173 (void) close(eport);
174 return (1);
175 }
176 if (port_get(eport, &pe, NULL) != 0) {
177 perror("port_get");
178 (void) close(sock);
179 (void) close(eport);
180 return (1);
181 }
182 assert(pe.portev_source == PORT_SOURCE_FD);
183 assert(pe.portev_object == (uintptr_t)sock);
184 if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &sz) != 0) {
185 perror("getsockopt");
186 (void) close(sock);
187 (void) close(eport);
188 return (1);
189 }
190 if (err != 0) {
191 /* Asynch connect failed */
192 fprintf(stderr, "asnchronous connect: %s\\n",
193 strerror(err));
194 (void) close(sock);
195 (void) close(eport);
196 return (1);
197 }
198 }
199
200 /* Read and write to the socket and then clean up */
201
202 return (0);
203 }
204 .fi
205 .in -2
206 .SH RETURN VALUES
207 .LP
208 If the connection or binding succeeds, \fB0\fR is returned. Otherwise,
209 \fB\(mi1\fR is returned and sets \fBerrno\fR to indicate the error.
210 .SH ERRORS
211 .LP
212 The call fails if:
|
172 (void) close(sock);
173 (void) close(eport);
174 return (1);
175 }
176 if (port_get(eport, &pe, NULL) != 0) {
177 perror("port_get");
178 (void) close(sock);
179 (void) close(eport);
180 return (1);
181 }
182 assert(pe.portev_source == PORT_SOURCE_FD);
183 assert(pe.portev_object == (uintptr_t)sock);
184 if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &sz) != 0) {
185 perror("getsockopt");
186 (void) close(sock);
187 (void) close(eport);
188 return (1);
189 }
190 if (err != 0) {
191 /* Asynch connect failed */
192 fprintf(stderr, "asynchronous connect: %s\\n",
193 strerror(err));
194 (void) close(sock);
195 (void) close(eport);
196 return (1);
197 }
198 }
199
200 /* Read and write to the socket and then clean up */
201
202 return (0);
203 }
204 .fi
205 .in -2
206 .SH RETURN VALUES
207 .LP
208 If the connection or binding succeeds, \fB0\fR is returned. Otherwise,
209 \fB\(mi1\fR is returned and sets \fBerrno\fR to indicate the error.
210 .SH ERRORS
211 .LP
212 The call fails if:
|