4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
36 #include <socket_inet.h>
40 * Description: Use recv in non-secure sockets.
42 * Arguments: fildes - Socket file descriptor.
43 * buf - Buffer to read data into.
44 * nbyte - Number of bytes to read.
45 * read_timeout - Timeout value in seconds.
46 * Returns: n - Number of bytes read. -1 on error.
49 socket_read(int fildes
, void *buf
, size_t nbyte
, int read_timeout
)
56 switch (poll(&pfd
, 1, read_timeout
* 1000)) {
66 return (recv(fildes
, buf
, nbyte
, 0));
71 * Description: Use sendto for non-secure connections.
73 * Arguments: fildes - Socket file descriptor.
74 * buf - Buffer containing data to be written.
75 * nbyte - Number of bytes to write.
76 * addr - Connection address
77 * Returns: n - Number of bytes written. -1 on error.
80 socket_write(int fildes
, const void *buf
, size_t nbyte
,
81 struct sockaddr_in
*addr
)
83 return (sendto(fildes
, buf
, nbyte
, 0, (struct sockaddr
*)addr
,
88 socket_close(int fildes
)
90 return (close(fildes
));