Socket.Socket
Class Overview | Class Members |
This Package |
All Packages
protected Socket()
Description
Creates an unconnected socket, with the
system-default type of SocketImpl.
protected Socket( SocketImpl impl ) throws SocketException
Description
Creates an unconnected Socket with a user-specified
SocketImpl.
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
Parameters
- host
- the host name.
- port
- the port number.
Description
Creates a stream socket and connects it to the specified port
number on the named host.
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.
Exceptions
IOException
if an I/O error occurs when creating the socket.
See Also
setSocketImplFactory, SocketImpl, createSocketImpl
public Socket( InetAddress address,
int port ) throws IOException
Parameters
- address
- the IP address.
- port
- the port number.
Description
Creates a stream socket and connects it to the specified port
number at the specified IP address.
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.
Exceptions
IOException
if an I/O error occurs when creating the socket.
See Also
setSocketImplFactory, SocketImpl, createSocketImpl
public Socket( String host,
int port,
InetAddress localAddr,
int localPort ) throws IOException
Parameters
- 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
Description
Creates a socket and connects it to the specified remote host on
the specified remote port. The Socket will also bind() to the local
address and port supplied.
public Socket( InetAddress address,
int port,
InetAddress localAddr,
int localPort ) throws IOException
Parameters
- 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
Description
Creates a socket and connects it to the specified remote address on
the specified remote port. The Socket will also bind() to the local
address and port supplied.
public Socket( String host,
int port,
boolean stream ) throws IOException
Parameters
- host
- the host name.
- port
- the port number.
- stream
- a boolean indicating whether this is
a stream socket or a datagram socket.
Description
Note: Socket() is deprecated.
Use DatagramSocket instead for UDP transport.
Creates a stream socket and connects it to the specified port
number on the named host.
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.
Exceptions
IOException
if an I/O error occurs when creating the socket.
See Also
setSocketImplFactory, SocketImpl, createSocketImpl
public Socket( InetAddress host,
int port,
boolean stream ) throws IOException
Parameters
- address
- the IP address.
- port
- the port number.
- stream
- if true, create a stream socket;
otherwise, create a datagram socket.
Description
Note: Socket() is deprecated.
Use DatagramSocket instead for UDP transport.
Creates a socket and connects it to the specified port number at
the specified IP address.
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.
Exceptions
IOException
if an I/O error occurs when creating the socket.
See Also
setSocketImplFactory, SocketImpl, createSocketImpl