001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.harmony.luni.platform;
019:
020: import java.io.FileDescriptor;
021: import java.io.IOException;
022: import java.net.DatagramPacket;
023: import java.net.InetAddress;
024: import java.net.SocketException;
025: import java.net.SocketImpl;
026: import java.net.UnknownHostException;
027: import java.nio.channels.Channel;
028:
029: /*
030: * The interface for network methods.
031: */
032: public interface INetworkSystem {
033:
034: /*
035: * Socket connect Step start
036: */
037: public final int SOCKET_CONNECT_STEP_START = 0;
038:
039: /*
040: * Socket connect Step check
041: */
042: public final int SOCKET_CONNECT_STEP_CHECK = 1;
043:
044: /*
045: * socket accept
046: */
047: public void accept(FileDescriptor fdServer, SocketImpl newSocket,
048: FileDescriptor fdnewSocket, int timeout) throws IOException;
049:
050: public void bind(FileDescriptor aFD, int port,
051: InetAddress inetAddress) throws SocketException;
052:
053: public boolean bind2(FileDescriptor aFD, int port,
054: boolean bindToDevice, InetAddress inetAddress)
055: throws SocketException;
056:
057: public void createSocket(FileDescriptor fd, boolean preferIPv4Stack)
058: throws IOException;
059:
060: public int read(FileDescriptor aFD, byte[] data, int offset,
061: int count, int timeout) throws IOException;
062:
063: public int readDirect(FileDescriptor aFD, long address, int count,
064: int timeout) throws IOException;
065:
066: public int write(FileDescriptor fd, byte[] data, int offset,
067: int count) throws IOException;
068:
069: public int writeDirect(FileDescriptor fd, long address, int count)
070: throws IOException;
071:
072: public void setNonBlocking(FileDescriptor aFD, boolean block)
073: throws IOException;
074:
075: public int connect(FileDescriptor aFD, int trafficClass,
076: InetAddress inetAddress, int port) throws IOException;
077:
078: public int connectWithTimeout(FileDescriptor aFD, int timeout,
079: int trafficClass, InetAddress hostname, int port, int step,
080: Long context) throws IOException;
081:
082: public int sendDatagram(FileDescriptor fd, byte[] data, int offset,
083: int length, int port, boolean bindToDevice,
084: int trafficClass, InetAddress inetAddress)
085: throws IOException;
086:
087: public int sendDatagramDirect(FileDescriptor fd, long address,
088: int offset, int length, int port, boolean bindToDevice,
089: int trafficClass, InetAddress inetAddress)
090: throws IOException;
091:
092: public int receiveDatagram(FileDescriptor aFD,
093: DatagramPacket packet, byte[] data, int offset, int length,
094: int receiveTimeout, boolean peek) throws IOException;
095:
096: public int receiveDatagramDirect(FileDescriptor aFD,
097: DatagramPacket packet, long address, int offset,
098: int length, int receiveTimeout, boolean peek)
099: throws IOException;
100:
101: public int recvConnectedDatagram(FileDescriptor aFD,
102: DatagramPacket packet, byte[] data, int offset, int length,
103: int receiveTimeout, boolean peek) throws IOException;
104:
105: public int recvConnectedDatagramDirect(FileDescriptor aFD,
106: DatagramPacket packet, long address, int offset,
107: int length, int receiveTimeout, boolean peek)
108: throws IOException;
109:
110: public int peekDatagram(FileDescriptor aFD, InetAddress sender,
111: int receiveTimeout) throws IOException;
112:
113: public int sendConnectedDatagram(FileDescriptor fd, byte[] data,
114: int offset, int length, boolean bindToDevice)
115: throws IOException;
116:
117: public int sendConnectedDatagramDirect(FileDescriptor fd,
118: long address, int offset, int length, boolean bindToDevice)
119: throws IOException;
120:
121: public void disconnectDatagram(FileDescriptor aFD)
122: throws SocketException;
123:
124: public void createDatagramSocket(FileDescriptor aFD,
125: boolean preferIPv4Stack) throws SocketException;
126:
127: public void connectDatagram(FileDescriptor aFD, int port,
128: int trafficClass, InetAddress inetAddress)
129: throws SocketException;
130:
131: public void createMulticastSocket(FileDescriptor aFD,
132: boolean preferIPv4Stack) throws SocketException;
133:
134: public void createServerStreamSocket(FileDescriptor aFD,
135: boolean preferIPv4Stack) throws SocketException;
136:
137: public int receiveStream(FileDescriptor aFD, byte[] data,
138: int offset, int count, int timeout) throws IOException;
139:
140: public int sendStream(FileDescriptor fd, byte[] data, int offset,
141: int count) throws IOException;
142:
143: public void shutdownInput(FileDescriptor descriptor)
144: throws IOException;
145:
146: public void shutdownOutput(FileDescriptor descriptor)
147: throws IOException;
148:
149: public boolean supportsUrgentData(FileDescriptor fd);
150:
151: public void sendUrgentData(FileDescriptor fd, byte value);
152:
153: public int availableStream(FileDescriptor aFD)
154: throws SocketException;
155:
156: public void acceptStreamSocket(FileDescriptor fdServer,
157: SocketImpl newSocket, FileDescriptor fdnewSocket,
158: int timeout) throws IOException;
159:
160: public void createStreamSocket(FileDescriptor aFD,
161: boolean preferIPv4Stack) throws SocketException;
162:
163: public void listenStreamSocket(FileDescriptor aFD, int backlog)
164: throws SocketException;
165:
166: public void connectStreamWithTimeoutSocket(FileDescriptor aFD,
167: int aport, int timeout, int trafficClass,
168: InetAddress inetAddress) throws IOException;
169:
170: public int sendDatagram2(FileDescriptor fd, byte[] data,
171: int offset, int length, int port, InetAddress inetAddress)
172: throws IOException;
173:
174: public InetAddress getSocketLocalAddress(FileDescriptor aFD,
175: boolean preferIPv6Addresses);
176:
177: public int[] select(FileDescriptor[] readFDs,
178: FileDescriptor[] writeFDs, long timeout)
179: throws SocketException;
180:
181: /*
182: * Query the IP stack for the local port to which this socket is bound.
183: *
184: * @param aFD the socket descriptor @param preferIPv6Addresses address
185: * preference for nodes that support both IPv4 and IPv6 @return int the
186: * local port to which the socket is bound
187: */
188: public int getSocketLocalPort(FileDescriptor aFD,
189: boolean preferIPv6Addresses);
190:
191: /*
192: * Query the IP stack for the nominated socket option.
193: *
194: * @param aFD the socket descriptor @param opt the socket option type
195: * @return the nominated socket option value
196: *
197: * @throws SocketException if the option is invalid
198: */
199: public Object getSocketOption(FileDescriptor aFD, int opt)
200: throws SocketException;
201:
202: /*
203: * Set the nominated socket option in the IP stack.
204: *
205: * @param aFD the socket descriptor @param opt the option selector @param
206: * optVal the nominated option value
207: *
208: * @throws SocketException if the option is invalid or cannot be set
209: */
210: public void setSocketOption(FileDescriptor aFD, int opt,
211: Object optVal) throws SocketException;
212:
213: public int getSocketFlags();
214:
215: /*
216: * Close the socket in the IP stack.
217: *
218: * @param aFD the socket descriptor
219: */
220: public void socketClose(FileDescriptor aFD) throws IOException;
221:
222: public InetAddress getHostByAddr(byte[] addr)
223: throws UnknownHostException;
224:
225: public InetAddress getHostByName(String addr,
226: boolean preferIPv6Addresses) throws UnknownHostException;
227:
228: public void setInetAddress(InetAddress sender, byte[] address);
229:
230: public boolean isReachableByICMP(InetAddress dest,
231: InetAddress source, int ttl, int timeout);
232:
233: public Channel inheritedChannel();
234:
235: public void oneTimeInitialization(boolean jcl_supports_ipv6);
236: }
|