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()) {
242 public static Object getSocketOption(FileDescriptor fd, int option) throws SocketException {
244 return getSocketOptionErrno(fd, option);
250 private static Object getSocketOptionErrno(FileDescriptor fd, int option) throws ErrnoException, SocketException {
254 return Libcore.os.getsockoptInAddr(fd, IPPROTO_IP, IP_MULTICAST_IF);
257 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF);
261 return booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP));
265 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
269 return Libcore.os.getsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS);
271 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_BROADCAST));
273 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE));
275 StructLinger linger = Libcore.os.getsockoptLinger(fd, SOL_SOCKET, SO_LINGER);
281 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE));
283 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_SNDBUF);
285 return booleanFromInt(Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR));
287 return Libcore.os.getsockoptInt(fd, SOL_SOCKET, SO_SNDBUF);
289 return (int) Libcore.os.getsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO).toMillis();
291 return booleanFromInt(Libcore.os.getsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY));
309 public static void setSocketOption(FileDescriptor fd, int option, Object value) throws SocketException {
311 setSocketOptionErrno(fd, option, value);
317 private static void setSocketOptionErrno(FileDescriptor fd, int option, Object value) throws ErrnoException, SocketException {
323 Libcore.os.setsockoptIpMreqn(fd, IPPROTO_IP, IP_MULTICAST_IF, (Integer) value);
324 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, (Integer) value);
328 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_LOOP, booleanToInt((Boolean) value));
329 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, booleanToInt((Boolean) value));
334 Libcore.os.setsockoptByte(fd, IPPROTO_IP, IP_MULTICAST_TTL, (Integer) value);
335 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (Integer) value);
338 Libcore.os.setsockoptInt(fd, IPPROTO_IP, IP_TOS, (Integer) value);
339 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_TCLASS, (Integer) value);
342 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_BROADCAST, booleanToInt((Boolean) value));
345 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_KEEPALIVE, booleanToInt((Boolean) value));
355 Libcore.os.setsockoptLinger(fd, SOL_SOCKET, SO_LINGER, linger);
358 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_OOBINLINE, booleanToInt((Boolean) value));
361 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_RCVBUF, (Integer) value);
364 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_REUSEADDR, booleanToInt((Boolean) value));
367 Libcore.os.setsockoptInt(fd, SOL_SOCKET, SO_SNDBUF, (Integer) value);
372 Libcore.os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, tv);
375 Libcore.os.setsockoptInt(fd, IPPROTO_TCP, TCP_NODELAY, booleanToInt((Boolean) value));
382 Libcore.os.setsockoptGroupReq(fd, level, op, groupReq);
396 FileDescriptor fd = null;
400 fd = Libcore.os.open(path, flags, mode);
401 if (fd.valid()) {
404 if (S_ISDIR(Libcore.os.fstat(fd).st_mode)) {
408 return fd;
411 if (fd != null) {
412 IoUtils.close(fd);
426 public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
432 int readCount = Libcore.os.read(fd, bytes, byteOffset, byteCount);
450 public static void write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
457 int bytesWritten = Libcore.os.write(fd, bytes, byteOffset, byteCount);
466 public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws IOException {
473 result = Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port);
480 public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws IOException {
487 result = Libcore.os.sendto(fd, buffer, flags, inetAddress, port);
509 public static int recvfrom(boolean isRead, FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
513 result = Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress);
521 public static int recvfrom(boolean isRead, FileDescriptor fd, ByteBuffer buffer, int flags, DatagramPacket packet, boolean isConnected) throws IOException {
525 result = Libcore.os.recvfrom(fd, buffer, flags, srcAddress);
566 FileDescriptor fd;
568 fd = Libcore.os.socket(AF_INET6, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
578 Libcore.os.setsockoptInt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, 1);
581 return fd;
587 public static InetAddress getSocketLocalAddress(FileDescriptor fd) {
589 SocketAddress sa = Libcore.os.getsockname(fd);
597 public static int getSocketLocalPort(FileDescriptor fd) {
599 SocketAddress sa = Libcore.os.getsockname(fd);