Lines Matching refs:fd

49     public static int available(FileDescriptor fd) throws IOException {
52 Libcore.os.ioctlInt(fd, FIONREAD, available);
54 // If the fd refers to a regular file, the result is the difference between
56 // is past the end of the file. If the fd refers to a special file masquerading
65 // The fd is unwilling to opine about its read buffer.
73 public static void bind(FileDescriptor fd, InetAddress address, int port) throws SocketException {
87 Libcore.os.bind(fd, address, port);
95 * Connects socket 'fd' to 'inetAddress' on 'port', with no timeout. The lack of a timeout
98 public static boolean connect(FileDescriptor fd, InetAddress inetAddress, int port) throws SocketException {
100 return IoBridge.connect(fd, inetAddress, port, 0);
107 * Connects socket 'fd' to 'inetAddress' on 'port', with a the given 'timeoutMs'.
110 public static boolean connect(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs) throws SocketException, SocketTimeoutException {
112 return connectErrno(fd, inetAddress, port, timeoutMs);
124 private static boolean connectErrno(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs) throws ErrnoException, IOException {
127 Libcore.os.connect(fd, inetAddress, port);
139 IoUtils.setBlocking(fd, false);
144 Libcore.os.connect(fd, inetAddress, port);
145 IoUtils.setBlocking(fd, true); // 4. set the socket back to blocking.
161 } while (!IoBridge.isConnected(fd, inetAddress, port, timeoutMs, remainingTimeoutMs));
162 IoUtils.setBlocking(fd, true); // 4. set the socket back to blocking.
177 public static void closeSocket(FileDescriptor fd) throws IOException {
178 if (!fd.valid()) {
182 int intFd = fd.getInt$();
183 fd.setInt$(-1);
194 public static boolean isConnected(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs, int remainingTimeoutMs) throws IOException {
198 pollFds[0].fd = fd;
204 int connectError = Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_ERROR);
210 if (!fd.valid()) {
235 public static Object getSocketOption(FileDescriptor fd, int option) throws SocketException {
237 return getSocketOptionErrno(fd, option);
243 private static Object getSocketOptionErrno(FileDescriptor fd, int option) throws ErrnoException, SocketException {
247 return Libcore.os.getsockoptInAddr(fd, IPPROTO_IP, IP_MULTICAST_IF);
250 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF);
254 return booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP));
258 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
262 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS);
264 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_BROADCAST));
266 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE));
268 StructLinger linger = Libcore.os.getsockoptLinger(fd, SOL_SOCKET, SO_LINGER);
274 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE));
276 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_RCVBUF);
278 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR));
280 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_SNDBUF);
282 return (int) Libcore.os.getsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO).toMillis();
284 return booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY));
302 public static void setSocketOption(FileDescriptor fd, int option, Object value) throws SocketException {
304 setSocketOptionErrno(fd, option, value);
310 private static void setSocketOptionErrno(FileDescriptor fd, int option, Object value) throws ErrnoException, SocketException {
316 Libcore.os.setsockoptIpMreqn(fd, IPPROTO_IP, IP_MULTICAST_IF, (Integer) value);
317 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, (Integer) value);
321 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_LOOP, booleanToInt((Boolean) value));
322 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, booleanToInt((Boolean) value));
327 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_TTL, (Integer) value);
328 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (Integer) value);
331 Libcore.os.setsockoptInt(fd, IPPROTO_IP, IP_TOS, (Integer) value);
332 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS, (Integer) value);
335 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_BROADCAST, booleanToInt((Boolean) value));
338 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE, booleanToInt((Boolean) value));
348 Libcore.os.setsockoptLinger(fd, SOL_SOCKET, SO_LINGER, linger);
351 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE, booleanToInt((Boolean) value));
354 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_RCVBUF, (Integer) value);
357 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR, booleanToInt((Boolean) value));
360 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_SNDBUF, (Integer) value);
365 Libcore.os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, tv);
368 Libcore.os.setsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY, booleanToInt((Boolean) value));
375 Libcore.os.setsockoptGroupReq(fd, level, op, groupReq);
389 FileDescriptor fd = null;
393 fd = Libcore.os.open(path, flags, mode);
394 if (fd.valid()) {
397 if (S_ISDIR(Libcore.os.fstat(fd).st_mode)) {
401 return fd;
404 if (fd != null) {
405 IoUtils.close(fd);
419 public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
425 int readCount = Libcore.os.read(fd, bytes, byteOffset, byteCount);
443 public static void write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
450 int bytesWritten = Libcore.os.write(fd, bytes, byteOffset, byteCount);
459 public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws IOException {
466 result = Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port);
473 public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws IOException {
480 result = Libcore.os.sendto(fd, buffer, flags, inetAddress, port);
502 public static int recvfrom(boolean isRead, FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
506 result = Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress);
514 public static int recvfrom(boolean isRead, FileDescriptor fd, ByteBuffer buffer, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
518 result = Libcore.os.recvfrom(fd, buffer, flags, srcAddress);
559 FileDescriptor fd;
561 fd = Libcore.os.socket(AF_INET6, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
571 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, 1);
574 return fd;
580 public static InetAddress getSocketLocalAddress(FileDescriptor fd) throws SocketException {
582 SocketAddress sa = Libcore.os.getsockname(fd);
590 public static int getSocketLocalPort(FileDescriptor fd) throws SocketException {
592 SocketAddress sa = Libcore.os.getsockname(fd);