|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.Socket
The client Socket class. It uses a SocketImpl to implement the actual socket operations. It is done this way so that you are able to change socket implementations depending on the kind of firewall that is used. You can change socket implementations by setting the SocketImplFactory.
Constructor Summary | |
Socket(InetAddress address,
int port)
Creates a stream socket and connects it to the specified address on the specified port. |
|
Socket(InetAddress address,
int port,
boolean stream)
Creates a socket and connects it to the specified address on the specified port. |
|
Socket(String host,
int port)
Creates a stream socket and connects it to the specified port on the specified host. |
|
Socket(String host,
int port,
boolean stream)
Creates a socket and connects it to the specified port on the specified host. |
Method Summary | |
void |
close()
Closes the socket. |
InetAddress |
getInetAddress()
Gets the address to which the socket is connected. |
InputStream |
getInputStream()
Gets an InputStream for this socket. |
int |
getLocalPort()
Gets the local port to which the socket is connected. |
OutputStream |
getOutputStream()
Gets an OutputStream for this socket. |
int |
getPort()
Gets the remote port to which the socket is connected. |
static void |
setSocketImplFactory(SocketImplFactory fac)
Sets the system's client SocketImplFactory. |
String |
toString()
Converts the Socket to a String. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Socket(String host, int port) throws UnknownHostException, IOException
host
- the hostport
- the portpublic Socket(String host, int port, boolean stream) throws IOException
host
- the specified hostport
- the specified portstream
- a boolean indicating whether this is a stream
or datagram socketpublic Socket(InetAddress address, int port) throws IOException
address
- the specified addressport
- the specified portpublic Socket(InetAddress address, int port, boolean stream) throws IOException
address
- the specified addressport
- the specified portstream
- a boolean indicating whether this is a stream
or datagram socketMethod Detail |
public InetAddress getInetAddress()
public int getPort()
public int getLocalPort()
public InputStream getInputStream() throws IOException
IOException
public OutputStream getOutputStream() throws IOException
IOException
public void close() throws IOException
IOException
public String toString()
toString
in class Object
public static void setSocketImplFactory(SocketImplFactory fac) throws IOException
fac
- the desired factory
SocketException
- If the factory is already defined.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |