Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.net.Socket
The actual work of the socket is performed by an instance of the
SocketImpl
class. An application, by changing
the socket factory that creates the socket implementation,
can configure itself to create sockets appropriate to the local
firewall.
Constructor Summary | |
Socket()
|
|
Socket(SocketImpl impl)
|
|
Socket(String host,
int port)
|
|
Socket(InetAddress address,
int port)
|
|
Socket(String host,
int port,
InetAddress localAddr,
int localPort)
|
|
Socket(InetAddress address,
int port,
InetAddress localAddr,
int localPort)
|
|
Socket(String host,
int port,
boolean stream)
|
|
Socket(InetAddress host,
int port,
boolean stream)
|
Method Summary | |
void | close()
|
InetAddress | getInetAddress()
|
InputStream | getInputStream()
|
InetAddress | getLocalAddress()
|
int | getLocalPort()
|
OutputStream | getOutputStream()
|
int | getPort()
|
int | getSoLinger()
|
int | getSoTimeout()
|
boolean | getTcpNoDelay()
|
static void | setSocketImplFactory(SocketImplFactory fac)
|
void | setSoLinger(boolean on,
int val)
|
void | setSoTimeout(int timeout)
|
void | setTcpNoDelay(boolean on)
|
String | toString()
String .
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Socket()
protected Socket(SocketImpl impl) throws SocketException
The impl parameter is an instance of a SocketImpl the subclass wishes to use on the Socket.
public Socket(String host, int port) throws UnknownHostException, IOException
If the application has specified a server socket factory, that
factory's createSocketImpl
method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
host
- the host name.
port
- the port number.
public Socket(InetAddress address, int port) throws IOException
If the application has specified a socket factory, that factory's
createSocketImpl
method is called to create the
actual socket implementation. Otherwise a "plain" socket is created.
address
- the IP address.
port
- the port number.
public Socket(String host, int port, InetAddress localAddr, int localPort) throws IOException
host
- the name of the remote host
port
- the remote port
localAddr
- the local address the socket is bound to
localPort
- the local port the socket is bound to
public Socket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException
address
- the remote address
port
- the remote port
localAddr
- the local address the socket is bound to
localPort
- the local port the socket is bound to
public Socket(String host, int port, boolean stream) throws IOException
If the stream argument is true
, this creates a
stream socket. If the stream argument is false
, it
creates a datagram socket.
If the application has specified a server socket factory, that
factory's createSocketImpl
method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
host
- the host name.
port
- the port number.
stream
- a boolean
indicating whether this is
a stream socket or a datagram socket.
public Socket(InetAddress host, int port, boolean stream) throws IOException
If the stream argument is true
, this creates a
stream socket. If the stream argument is false
, it
creates a datagram socket.
If the application has specified a server socket factory, that
factory's createSocketImpl
method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
address
- the IP address.
port
- the port number.
stream
- if true
, create a stream socket;
otherwise, create a datagram socket.
Method Detail |
public InetAddress getInetAddress()
public InetAddress getLocalAddress()
public int getPort()
public int getLocalPort()
public InputStream getInputStream() throws IOException
public OutputStream getOutputStream() throws IOException
public void setTcpNoDelay(boolean on) throws SocketException
public boolean getTcpNoDelay() throws SocketException
public void setSoLinger(boolean on, int val) throws SocketException
public int getSoLinger() throws SocketException
public void setSoTimeout(int timeout) throws SocketException
public int getSoTimeout() throws SocketException
public void close() throws IOException
public String toString()
String
.public static void setSocketImplFactory(SocketImplFactory fac) throws IOException
When an application creates a new client socket, the socket
implementation factory's createSocketImpl
method is
called to create the actual socket implementation.
fac
- the desired factory.
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |