Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.net
Class Socket

    java.lang.Object
      jcontrol.net.Socket

    public class Socket

extends Object

JControl - Socket Implementation

Constructor Summary
`protected` | `Socket()` Creates a stream socket that not connects to the any specified port number or specified IP address.
`` | `Socket(InetAddress address, int port)` Creates a stream socket and connects it to the specified port number at the specified IP address.

Method Summary
`void` | `close()` Closes this socket.
`protected void` | `finalize()` Free internal data structures used by this socket object.
`InetAddress` | `getInetAddress()` Returns the address to which the socket is connected.
`BasicInputStream` | `getInputStream()` Returns an input stream for this socket.
`BasicOutputStream` | `getOutputStream()` Returns an output stream for this socket.
`int` | `getPort()` Returns the remote port to which this socket is connected.
`boolean` | `isClosed()` Returns the closed state of the socket.
`boolean` | `isConnected()` Returns the connection state of the socket.

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Constructor Detail

### Socket

    protected Socket()

  Creates a stream socket that not connects to the any specified port number or specified IP address.

### Socket

    public Socket(InetAddress address,
                  int port)
           throws IOException

  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.

  Parameters:
    `address` - - the IP address.
    `port` - - the port number.
  Throws:
    `IOException` - - if an I/O error occurs when creating the socket.

Method Detail

### getInetAddress

    public InetAddress getInetAddress()

  Returns the address to which the socket is connected.

  Returns:
    the remote IP address to which this socket is connected, or null if the socket is not connected.

### getInputStream

    public BasicInputStream getInputStream()
                                    throws IOException

  Returns an input stream for this socket. If this socket has an associated channel then the resulting input stream delegates all of its operations to the channel. Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream : If there are no bytes buffered on the socket, or all buffered bytes have been consumed by read, then all subsequent calls to read will throw an IOException.

  Returns:
    - an input stream for reading bytes from this socket.
  Throws:
    `-` - IOException - if an I/O error occurs when creating the input stream, the socket is closed or the socket is not connected
    `IOException`

### getOutputStream

    public BasicOutputStream getOutputStream()
                                      throws IOException

  Returns an output stream for this socket. If this socket has an associated channel then the resulting output stream delegates all of its operations to the channel.

  Returns:
    -an output stream for writing bytes to this socket.
  Throws:
    `IOException` - - if an I/O error occurs when creating the output stream or if the socket is not connected.

### close

    public void close()
               throws IOException

  Closes this socket. Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created. If this socket has an associated channel then the channel is closed as well.

  Throws:
    `IOException` - - if an I/O error occurs when closing this socket.
  See Also:
    `isClosed()`

### isClosed

    public boolean isClosed()

  Returns the closed state of the socket.

  Returns:
    true if the socket has been closed
  See Also:
    `close()`

### getPort

    public int getPort()

  Returns the remote port to which this socket is connected.

  Returns:
    the remote port number to which this socket is connected, or 0 if the socket is not connected yet.

### isConnected

    public boolean isConnected()

  Returns the connection state of the socket.

  Returns:
    true if the socket successfuly connected to a server

### finalize

    protected void finalize()

  Free internal data structures used by this socket object.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD