Lines Matching refs:fd

57     public static int available(FileDescriptor fd) throws IOException {
60 Libcore.os.ioctlInt(fd, FIONREAD, available);
62 // If the fd refers to a regular file, the result is the difference between
64 // is past the end of the file. If the fd refers to a special file masquerading
73 // The fd is unwilling to opine about its read buffer.
81 public static void bind(FileDescriptor fd, InetAddress address, int port) throws SocketException {
99 Libcore.os.bind(fd, address, port);
112 * Connects socket 'fd' to 'inetAddress' on 'port', with no timeout. The lack of a timeout
115 public static void connect(FileDescriptor fd, InetAddress inetAddress, int port) throws SocketException {
117 IoBridge.connect(fd, inetAddress, port, 0);
124 * Connects socket 'fd' to 'inetAddress' on 'port', with a the given 'timeoutMs'.
127 public static void connect(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs) throws SocketException, SocketTimeoutException {
129 connectErrno(fd, inetAddress, port, timeoutMs);
137 throw new ConnectException(createMessageForException(fd, inetAddress, port, timeoutMs,
148 private static void connectErrno(FileDescriptor fd, InetAddress inetAddress, int port, int timeoutMs) throws ErrnoException, IOException {
151 Libcore.os.connect(fd, inetAddress, port);
163 IoUtils.setBlocking(fd, false);
168 Libcore.os.connect(fd, inetAddress, port);
169 IoUtils.setBlocking(fd, true); // 4. set the socket back to blocking.
185 createMessageForException(fd, inetAddress, port, timeoutMs, null));
187 } while (!IoBridge.isConnected(fd, inetAddress, port, timeoutMs, remainingTimeoutMs));
188 IoUtils.setBlocking(fd, true); // 4. set the socket back to blocking.
194 private static String createMessageForException(FileDescriptor fd, InetAddress inetAddress,
196 // Figure out source address from fd.
199 localAddress = getLocalInetSocketAddress(fd);
236 public static void closeAndSignalBlockedThreads(FileDescriptor fd) throws IOException {
237 if (fd == null || !fd.valid()) {
240 int intFd = fd.getInt$();
241 fd.setInt$(-1);
252 public static boolean isConnected(FileDescriptor fd, InetAddress inetAddress, int port,
257 pollFds[0].fd = fd;
263 int connectError = Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_ERROR);
269 if (!fd.valid()) {
274 String detail = createMessageForException(fd, inetAddress, port, timeoutMs, cause);
291 public static Object getSocketOption(FileDescriptor fd, int option) throws SocketException {
293 return getSocketOptionErrno(fd, option);
299 private static Object getSocketOptionErrno(FileDescriptor fd, int option) throws ErrnoException, SocketException {
303 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF);
309 return !booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP));
313 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
317 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
321 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS);
323 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_BROADCAST));
325 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE));
327 StructLinger linger = Libcore.os.getsockoptLinger(fd, SOL_SOCKET, SO_LINGER);
333 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE));
335 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_RCVBUF);
337 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR));
339 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_SNDBUF);
341 return (int) Libcore.os.getsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO).toMillis();
343 return booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY));
345 return ((InetSocketAddress) Libcore.os.getsockname(fd)).getAddress();
363 public static void setSocketOption(FileDescriptor fd, int option, Object value) throws SocketException {
365 setSocketOptionErrno(fd, option, value);
371 private static void setSocketOptionErrno(FileDescriptor fd, int option, Object value) throws ErrnoException, SocketException {
380 Libcore.os.setsockoptIpMreqn(fd, IPPROTO_IP, IP_MULTICAST_IF, nif.getIndex());
381 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, nif.getIndex());
385 Libcore.os.setsockoptIpMreqn(fd, IPPROTO_IP, IP_MULTICAST_IF, (Integer) value);
386 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, (Integer) value);
393 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_LOOP, enable);
394 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, enable);
399 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_TTL, (Integer) value);
400 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (Integer) value);
403 Libcore.os.setsockoptInt(fd, IPPROTO_IP, IP_TTL, (Integer) value);
404 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (Integer) value);
407 Libcore.os.setsockoptInt(fd, IPPROTO_IP, IP_TOS, (Integer) value);
408 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS, (Integer) value);
411 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_BROADCAST, booleanToInt((Boolean) value));
414 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE, booleanToInt((Boolean) value));
424 Libcore.os.setsockoptLinger(fd, SOL_SOCKET, SO_LINGER, linger);
427 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE, booleanToInt((Boolean) value));
430 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_RCVBUF, (Integer) value);
433 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR, booleanToInt((Boolean) value));
436 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_SNDBUF, (Integer) value);
441 Libcore.os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, tv);
444 Libcore.os.setsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY, booleanToInt((Boolean) value));
452 Libcore.os.setsockoptGroupReq(fd, level, op, groupReq);
467 FileDescriptor fd = null;
471 fd = Libcore.os.open(path, flags, mode);
474 if (S_ISDIR(Libcore.os.fstat(fd).st_mode)) {
477 return fd;
480 if (fd != null) {
481 IoUtils.close(fd);
495 public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
501 int readCount = Libcore.os.read(fd, bytes, byteOffset, byteCount);
519 public static void write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
526 int bytesWritten = Libcore.os.write(fd, bytes, byteOffset, byteCount);
535 public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws IOException {
542 result = Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port);
549 public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws IOException {
556 result = Libcore.os.sendto(fd, buffer, flags, inetAddress, port);
579 public static int recvfrom(boolean isRead, FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
583 result = Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress);
591 public static int recvfrom(boolean isRead, FileDescriptor fd, ByteBuffer buffer, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
595 result = Libcore.os.recvfrom(fd, buffer, flags, srcAddress);
638 FileDescriptor fd;
640 fd = Libcore.os.socket(domain, type, protocol);
642 return fd;
655 public static void poll(FileDescriptor fd, int events, int timeout)
658 pollFds[0].fd = fd;
672 * @throws SocketException if fd is not currently bound to an InetSocketAddress
674 public static InetSocketAddress getLocalInetSocketAddress(FileDescriptor fd)
677 SocketAddress socketAddress = Libcore.os.getsockname(fd);