    All Packages    This Package    Previous    Next

# Class net.Socket

    java.lang.Object
       |
       +----net.Socket

public final class Socket
extends Object

##

address
  address this socket is bound to
inputStream
  file for doing input on this socket
outputStream
  file for doing output to other end
port
  Port this socket is bound to in network byte order.

##

Socket(boolean)
  Create a socket which is a TCP socket if isStream is true, or is a UDP socket otherwise.
Socket(String, int)
  Create a TCP socket and connect it to the specified port on the specified host.

##

accept()
  Accept a connection on this socket, returning a new one.
bindAnonymously(InetAddress)
  Bind this socket to a local address.
bindToPort(InetAddress, int)
  Bind this socket to a known port at the specified address.
close()
  Close the connection.
finalize()
initialize()
  This does nothing except provide an entry point for other related packages to cause the above static initializer to run.
listen(int)
  Specify how many connections can attempt to connect to this socket at once before getting an error.
toString()

##

address

      public InetAddress address

  address this socket is bound to

port

      public int port

  Port this socket is bound to in network byte order.

inputStream

      public FileInputStream inputStream

  file for doing input on this socket

outputStream

      public FileOutputStream outputStream

  file for doing output to other end

##

Socket

      public Socket(boolean isStream)

  Create a socket which is a TCP socket if isStream is true, or is a UDP socket otherwise.

Socket

      public Socket(String host,
                    int port)

  Create a TCP socket and connect it to the specified port on the specified host.

##

listen

      public void listen(int count)

  Specify how many connections can attempt to connect to this socket at once before getting an error.

initialize

      public static void initialize()

  This does nothing except provide an entry point for other related packages to cause the above static initializer to run.

bindAnonymously

      public void bindAnonymously(InetAddress addr)

  Bind this socket to a local address.

bindToPort

      public void bindToPort(InetAddress addr,
                             int port)

  Bind this socket to a known port at the specified address.

accept

      public Socket accept()

  Accept a connection on this socket, returning a new one. The old socket is still around for listening for new connections.

close

      public synchronized void close()

  Close the connection. Other end will get EOF on reads, and SIGPIPE on writes.

toString

      public String toString()

finalize

      protected void finalize()

    All Packages    This Package    Previous    Next