java.net

Class Socket

Known Direct Subclasses:
SlowSocket

public class Socket
extends Object

This class implements client sockets (also called just "sockets"). A socket is an endpoint for communication between two machines.

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.

Since:
JDK1.0
See Also:
setSocketImplFactory(SocketImplFactory), SocketImpl, SocketChannel

Constructor Summary

Socket()
Creates an unconnected socket, with the system-default type of SocketImpl.
Socket(String host, int port)
Creates a stream socket and connects it to the specified port number on the named host.
Socket(String host, int port, InetAddress localAddr, int localPort)
Creates a socket and connects it to the specified remote host on the specified remote port.
Socket(InetAddress address, int port)
Creates a stream socket and connects it to the specified port number at the specified IP address.
Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
Creates a socket and connects it to the specified remote address on the specified remote port.
Socket(Proxy proxy)
Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings.
Socket(SocketImpl impl)
Creates an unconnected Socket with a user-specified SocketImpl.

Method Summary

void
bind(SocketAddress bindpoint)
Binds the socket to a local address.
void
close()
Closes this socket.
void
connect(SocketAddress endpoint)
Connects this socket to the server.
void
connect(SocketAddress endpoint, int timeout)
Connects this socket to the server with a specified timeout value.
SocketChannel
getChannel()
Returns the unique SocketChannel object associated with this socket, if any.
InetAddress
getInetAddress()
Returns the address to which the socket is connected.
InputStream
getInputStream()
Returns an input stream for this socket.
boolean
getKeepAlive()
Tests if SO_KEEPALIVE is enabled.
InetAddress
getLocalAddress()
Gets the local address to which the socket is bound.
int
getLocalPort()
Returns the local port to which this socket is bound.
SocketAddress
getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
boolean
getOOBInline()
Tests if OOBINLINE is enabled.
OutputStream
getOutputStream()
Returns an output stream for this socket.
int
getPort()
Returns the remote port to which this socket is connected.
int
getReceiveBufferSize()
Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.
SocketAddress
getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
boolean
getReuseAddress()
Tests if SO_REUSEADDR is enabled.
int
getSendBufferSize()
Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
int
getSoLinger()
Returns setting for SO_LINGER.
int
getSoTimeout()
Returns setting for SO_TIMEOUT.
boolean
getTcpNoDelay()
Tests if TCP_NODELAY is enabled.
int
getTrafficClass()
Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

boolean
isBound()
Returns the binding state of the socket.
boolean
isClosed()
Returns the closed state of the socket.
boolean
isConnected()
Returns the connection state of the socket.
boolean
isInputShutdown()
Returns whether the read-half of the socket connection is closed.
boolean
isOutputShutdown()
Returns whether the write-half of the socket connection is closed.
void
sendUrgentData(int data)
Send one byte of urgent data on the socket.
void
setKeepAlive(boolean on)
Enable/disable SO_KEEPALIVE.
void
setOOBInline(boolean on)
Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.
void
setPerformancePreferences(int connectionTime, int latency, int bandwidth)
Sets performance preferences for this socket.
void
setReceiveBufferSize(int size)
Sets the SO_RCVBUF option to the specified value for this Socket.
void
setReuseAddress(boolean on)
Enable/disable the SO_REUSEADDR socket option.
void
setSendBufferSize(int size)
Sets the SO_SNDBUF option to the specified value for this Socket.
void
setSoLinger(boolean on, int linger)
Enable/disable SO_LINGER with the specified linger time in seconds.
void
setSoTimeout(int timeout)
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
static void
setSocketImplFactory(SocketImplFactory fac)
Sets the client socket implementation factory for the application.
void
setTcpNoDelay(boolean on)
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
void
setTrafficClass(int tc)
Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.
void
shutdownInput()
Places the input stream for this socket at "end of stream".
void
shutdownOutput()
Disables the output stream for this socket.
String
toString()
Converts this socket to a String.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Socket

public Socket()
Creates an unconnected socket, with the system-default type of SocketImpl.
Since:
JDK1.1
Usages and Demos :

View More Examples of Socket()
   1:         try {
   2:             Socket socket = new Socket();
   3:             InetSocketAddress socketAddress = new InetSocketAddress(hostname, port);
   4:             socket.connect(socketAddress, TIMEOUT_MILLISECONS);
   5:             return true;

View Full Code Here
   1: 
   2:   Socket s = new Socket();
   3: 
   4:   System.err.println("Setting TCP_NODELAY on");
   5:   s.setTcpNoDelay(true);

View Full Code Here
   1:         long begin=System.currentTimeMillis();
   2:         socket = new Socket();
   3:         long end=System.currentTimeMillis();
   4:     }catch (BindException e) {
   5:         result="Local address and port can't be binded";

View Full Code Here
   1:     {
   2:         final Socket socket = new Socket();
   3: 
   4:         socket.connect(new InetSocketAddress(host, port), timeout);

View Full Code Here
   1:         SocketAddress me = new InetSocketAddress("127.0.0.1",SERVER_PORT);
   2:         Socket s = new Socket();
   3:         s.connect(me);
   4:         OutputStream os = s.getOutputStream();
   5:         os.write("CONNECT \n\n".getBytes());

View Full Code Here

Socket

public Socket(String host,
              int port)
            throws UnknownHostException,
                   IOException
Creates a stream socket and connects it to the specified port number on the named host.

If the specified host is null it is the equivalent of specifying the address as InetAddress.getByName(null). In other words, it is equivalent to specifying an address of the loopback interface.

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.

If there is a security manager, its checkConnect method is called with the host address and port as its arguments. This could result in a SecurityException.

Parameters:
host - the host name, or null for the loopback address.
port - the port number.
Throws:
UnknownHostException - if the IP address of the host could not be determined.
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation.
Usages and Demos :

View More Examples of Socket(String host,int port)
   1:             {
   2:                 new Socket("", 0);
   3:                 return 2;
   4:             }
   5:         }

View Full Code Here
   1:         try {
   2:            Socket s = new Socket("127.0.0.1", 4200);
   3:            InputStreamReader streamReader = new InputStreamReader(s.getInputStream());
   4:            BufferedReader reader = new BufferedReader(streamReader);
   5:            String advice = reader.readLine();

View Full Code Here
   1: {
   2:             echoSocket = new Socket("10.65.111.101", 7);
   3:             out = new DataOutputStream(echoSocket.getOutputStream());
   4:             in = new DataInputStream(echoSocket.getInputStream());
   5:         }

View Full Code Here
   1: {
   2:             comSocket = new Socket("10.65.111.101",1800);
   3:             out = new PrintStream(comSocket.getOutputStream());
   4:             in = new DataInputStream(comSocket.getInputStream());
   5:         }

View Full Code Here
   1:         try {
   2:            sock = new Socket("127.0.0.1", 5000);
   3:           
   4:            writer = new PrintWriter(sock.getOutputStream());
   5:           

View Full Code Here

Socket

public Socket(String host,
              int port,
              InetAddress localAddr,
              int localPort)
            throws IOException
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.

If the specified host is null it is the equivalent of specifying the address as InetAddress.getByName(null). In other words, it is equivalent to specifying an address of the loopback interface.

If there is a security manager, its checkConnect method is called with the host address and port as its arguments. This could result in a SecurityException.

Parameters:
host - the name of the remote host, or null for the loopback address.
port - the remote port
localAddr - the local address the socket is bound to
localPort - the local port the socket is bound to
Throws:
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation.
Since:
JDK1.1
See Also:
SecurityManager.checkConnect
Usages and Demos :

View More Examples of Socket(String host,int port,InetAddress localAddr,int localPort)
   1:         if ((localAddress != null) && (localPort != 0))
   2:             sock = new Socket(addr, port, localAddress, localPort);
   3:         else
   4:             sock = new Socket(addr, port);

View Full Code Here
   1: 
   2:             return new Socket(host, port, localEndpoint, 0);
   3:         }
   4: 
   5:         return new Socket(host, port);

View Full Code Here
   1:         {
   2:             return new Socket( arg1, arg2, arg3, arg4 );
   3:         }
   4:         ...
   5:         {
   6:             return new Socket( arg1, arg2, arg3, arg4 );
   7:         }
   8:     }

View Full Code Here
   1:          {
   2:             socket = new Socket(hostAddr, port, localAddr, localPort);
   3:             synchronized( this )
   4:             {
   5:                this.notify();

View Full Code Here
   1:             {
   2:                 final Socket socket = new Socket(host, port, localHost, localPort);
   3:                 if (logger.isDebugEnabled())
   4:                 {
   5:                     logger.debug("PortRangeSocketFactory: Created server socket at "

View Full Code Here

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.

If there is a security manager, its checkConnect method is called with the host address and port as its arguments. This could result in a SecurityException.

Parameters:
address - the IP address.
port - the port number.
Throws:
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation.
Usages and Demos :

View More Examples of Socket(InetAddress address,int port)
   1:             {
   2:                 new Socket("", 0);
   3:                 return 2;
   4:             }
   5:         }

View Full Code Here
   1:         try {
   2:            Socket s = new Socket("127.0.0.1", 4200);
   3:            InputStreamReader streamReader = new InputStreamReader(s.getInputStream());
   4:            BufferedReader reader = new BufferedReader(streamReader);
   5:            String advice = reader.readLine();

View Full Code Here
   1: {
   2:             echoSocket = new Socket("10.65.111.101", 7);
   3:             out = new DataOutputStream(echoSocket.getOutputStream());
   4:             in = new DataInputStream(echoSocket.getInputStream());
   5:         }

View Full Code Here
   1: {
   2:             comSocket = new Socket("10.65.111.101",1800);
   3:             out = new PrintStream(comSocket.getOutputStream());
   4:             in = new DataInputStream(comSocket.getInputStream());
   5:         }

View Full Code Here
   1:         try {
   2:            sock = new Socket("127.0.0.1", 5000);
   3:           
   4:            writer = new PrintWriter(sock.getOutputStream());
   5:           

View Full Code Here

Socket

public Socket(InetAddress address,
              int port,
              InetAddress localAddr,
              int localPort)
            throws IOException
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.

If there is a security manager, its checkConnect method is called with the host address and port as its arguments. This could result in a SecurityException.

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
Throws:
IOException - if an I/O error occurs when creating the socket.
SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation.
Since:
JDK1.1
See Also:
SecurityManager.checkConnect
Usages and Demos :

View More Examples of Socket(InetAddress address,int port,InetAddress localAddr,int localPort)
   1:         if ((localAddress != null) && (localPort != 0))
   2:             sock = new Socket(addr, port, localAddress, localPort);
   3:         else
   4:             sock = new Socket(addr, port);

View Full Code Here
   1: 
   2:             return new Socket(host, port, localEndpoint, 0);
   3:         }
   4: 
   5:         return new Socket(host, port);

View Full Code Here
   1:         {
   2:             return new Socket( arg1, arg2, arg3, arg4 );
   3:         }
   4:         ...
   5:         {
   6:             return new Socket( arg1, arg2, arg3, arg4 );
   7:         }
   8:     }

View Full Code Here
   1:          {
   2:             socket = new Socket(hostAddr, port, localAddr, localPort);
   3:             synchronized( this )
   4:             {
   5:                this.notify();

View Full Code Here
   1:             {
   2:                 final Socket socket = new Socket(host, port, localHost, localPort);
   3:                 if (logger.isDebugEnabled())
   4:                 {
   5:                     logger.debug("PortRangeSocketFactory: Created server socket at "

View Full Code Here

Socket

public Socket(Proxy proxy)
Creates an unconnected socket, specifying the type of proxy, if any, that should be used regardless of any other settings.

If there is a security manager, its checkConnect method is called with the proxy host address and port number as its arguments. This could result in a SecurityException.

Examples:

  • Socket s = new Socket(Proxy.NO_PROXY); will create a plain socket ignoring any other proxy configuration.
  • Socket s = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("socks.mydom.com", 1080))); will create a socket connecting through the specified SOCKS proxy server.
Parameters:
proxy - a Proxy object specifying what kind of proxying should be used.
Throws:
IllegalArgumentException - if the proxy is of an invalid type or null.
SecurityException - if a security manager is present and permission to connect to the proxy is denied.
Since:
1.5
Usages and Demos :

View More Examples of Socket(Proxy proxy)
   1:     public Connection(String host, int port) throws IOException {
   2:         this(new Socket(MuffinResolver.getByName(host), port));
   3:     }
   4: 
   5:     public Connection() {}

View Full Code Here
   1:                 if (address instanceof InetAddress) {
   2:                     socket = new Socket((InetAddress)address, mKey.mPort);
   3:                 }
   4:         ...
   5:                 else {
   6:                     socket = new Socket(String.valueOf(address), mKey.mPort);
   7:                 }
   8: 
   9:                 synchronized (this) {

View Full Code Here
   1:         try {
   2:             socket = new Socket((String) null, 54321);
   3:             notUnique();
   4:         ...
   5: 
   6:         socket = new Socket((String) null, 54321);
   7:         input = "";
   8:         while ((b = socket.getInputStream().read()) != -1) {
   9:             input += (char) b;

View Full Code Here
   1:         try {
   2:             socket = new Socket(TEST_CONTAINER.getHost(),
   3:                                 TEST_CONTAINER.getPort());
   4: 
   5:             out = socket.getOutputStream();

View Full Code Here
   1:             Debug.info("connecting console to server at port " + port);
   2:             socket = new Socket((String) null, port);
   3:             writer = new BufferedWriter(new OutputStreamWriter(socket
   4:                     .getOutputStream()));
   5:             BufferedReader reader = new BufferedReader(new InputStreamReader(

View Full Code Here

Socket

protected Socket(SocketImpl impl)
            throws SocketException
Creates an unconnected Socket with a user-specified SocketImpl.

Parameters:
impl - an instance of a SocketImpl the subclass wishes to use on the Socket.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK1.1

Method Details

bind

public void bind(SocketAddress bindpoint)
            throws IOException
Binds the socket to a local address.

If the address is null, then the system will pick up an ephemeral port and a valid local address to bind the socket.

Parameters:
bindpoint - the SocketAddress to bind to
Throws:
IOException - if the bind operation fails, or if the socket is already bound.
IllegalArgumentException - if bindpoint is a SocketAddress subclass not supported by this socket
Since:
1.4
See Also:
isBound()
Usages and Demos :

View More Examples of bind(SocketAddress bindpoint)
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:   private Domain _domain;
   6:   private Socket _socket;
   7: 
   8:         ...
   9:   public SocketInputOutput(Env env, Socket socket, Domain domain)
  10:   {
  11:         ...
  12:   {
  13:     _socket.bind(address);

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
   7:         return socketFactory.createSocket(host, port);
   8:         ...
   9: 
  10:     public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
  11:             throws IOException, UnknownHostException {
  12:         ...
  13:             SocketAddress remoteaddr = new InetSocketAddress(host, port);
  14:             rval.bind(localaddr);

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.bind( bindpoint );

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:   final int port;
   6:   Socket socket;
   7:   DTPInputStream in;
   8:         ...
   9:     InetSocketAddress local = new InetSocketAddress(localhost, port + 1);
  10:     socket.bind(local);
  11:     if (connectionTimeout > 0)

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.bind(bindpoint);

View Full Code Here

close

public void close()
            throws IOException
Closes this socket.

Any thread currently blocked in an I/O operation upon this socket will throw a SocketException.

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()
Usages and Demos :

View More Examples of close()
   1:   public static void main(String args[])throws Exception {
   2:     Socket s = new Socket("localhost",8000);
   3:     OutputStream out=s.getOutputStream();
   4:         ...
   5:     out.write("everyone".getBytes());
   6:     s.close();
   7:   }
   8: }

View Full Code Here
   1:     ServerSocket serverSocket=new ServerSocket(8000);
   2:     Socket socket=serverSocket.accept(); 
   3:         ...
   4:     socket.close();
   5:     System.out.println("????????");
   6:   }
   7: }

View Full Code Here
   1: 
   2:       Socket s = new Socket(server, port);
   3: 
   4:         ...
   5: 
   6:       s.close();
   7:     }
   8:     catch(Exception e) {
   9:       System.out.println("Exception: " + e);

View Full Code Here
   1:     String host = args.length > 0 ? args[0] : "127.0.0.1";
   2:     Socket s = new Socket(host, 80);
   3:     PrintWriter aus = new PrintWriter(s.getOutputStream());
   4:         ...
   5:       System.out.println(line);
   6:     s.close();
   7:   }
   8: }

View Full Code Here
   1:     {
   2:       Socket client = sock.accept();
   3:       Thread.sleep(10000);
   4:         ...
   5:       client.close();
   6:     System.out.println("Closed from " + Thread.currentThread());
   7:     }
   8:     catch (Exception e)    { System.out.println(e);}

View Full Code Here

connect

public void connect(SocketAddress endpoint)
            throws IOException
Connects this socket to the server.
Parameters:
endpoint - the SocketAddress
Throws:
IOException - if an error occurs during the connection
IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode
IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket
Since:
1.4
Usages and Demos :

View More Examples of connect(SocketAddress endpoint)
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:         SocketAddress me = new InetSocketAddress("127.0.0.1",SERVER_PORT);
   6:         Socket s = new Socket();
   7:         ...
   8:         s.connect(me);
   9:         OutputStream os = s.getOutputStream();

View Full Code Here
   1: import java.net.MalformedURLException;
   2: import java.net.Socket;
   3: import java.net.URL;
   4:         ...
   5:             
   6:             Socket socket = new Socket();
   7:             
   8:         ...
   9:             InetSocketAddress remoteAddress = new InetSocketAddress(url.getHost(), port);
  10:             socket.connect(remoteAddress);
  11:             PrintWriter out = new PrintWriter(socket.getOutputStream());

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         Logger.getLogger(RemoteContentInputStream.class);
   6:     private Socket socket;
   7:     private OutputStream out;
   8:         ...
   9:         int timeout = 5000;
  10:         socket.connect(ref.getAddress(), timeout);

View Full Code Here
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:   private Domain _domain;
   6:   private Socket _socket;
   7: 
   8:         ...
   9:   public SocketInputOutput(Env env, Socket socket, Domain domain)
  10:   {
  11:         ...
  12:   {
  13:     _socket.connect(address);

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.UnknownHostException;
   4:         ...
   5: 
   6:   @Override public Socket createSocket(Socket socket, String host, int port,
   7:                                        boolean autoClose)
   8:         ...
   9:     InetSocketAddress endpoint = new InetSocketAddress(host, port);
  10:     socket.connect(endpoint);
  11:     return socket;

View Full Code Here

connect

public void connect(SocketAddress endpoint,
                    int timeout)
            throws IOException
Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs.
Parameters:
endpoint - the SocketAddress
timeout - the timeout value to be used in milliseconds.
Throws:
IOException - if an error occurs during the connection
IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode
IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket
Since:
1.4
Usages and Demos :

View More Examples of connect(SocketAddress endpoint,int timeout)
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         try {
   6:             Socket socket = new Socket();
   7:             InetSocketAddress socketAddress = new InetSocketAddress(hostname, port);
   8:         ...
   9:             socket.connect(socketAddress, TIMEOUT_MILLISECONS);
  10:             return true;

View Full Code Here
   1:     }
   2:     new ConnectTester().connect(host,port);
   3:   }
   4:         ...
   5:     SocketAddress remoteAddr=new InetSocketAddress(host,port);
   6:     Socket socket=null;
   7:     String result="";
   8:         ...
   9:         long begin=System.currentTimeMillis();
  10:         socket = new Socket();
  11:         long end=System.currentTimeMillis();

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:   final int port;
   6:   Socket socket;
   7:   DTPInputStream in;
   8:         ...
   9:       {
  10:         socket.connect(remote, connectionTimeout);
  11:       }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.connect(endpoint, timeout);

View Full Code Here
   1:                     {
   2:                         protected    Socket    socket;
   3:                         
   4:         ...
   5:                                 
   6:                                 socket = new Socket();
   7:                                                                 
   8:         ...
   9:                                 socket.connect( address, check_timeout );
  10:                             

View Full Code Here

getChannel

public SocketChannel getChannel()
Returns the unique SocketChannel object associated with this socket, if any.

A socket will have a channel if, and only if, the channel itself was created via the SocketChannel.open or ServerSocketChannel.accept methods.

Returns:
the socket channel associated with this socket, or null if this socket was not created for a channel
Since:
1.4
Usages and Demos :

View More Examples of getChannel()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getChannel();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public SocketChannel getChannel() {
  13:     return socket.getChannel();

View Full Code Here
   1: 
   2:   protected Socket socket;
   3:   protected SocketChannel socketChannel;
   4:         ...
   5: 
   6:   protected ProjectFileChannelProtocol(Socket socket) {
   7:     this();
   8:         ...
   9:     this.socket = socket;
  10:     this.socketChannel = socket.getChannel();
  11:     this.buffer = ByteBuffer.allocate(1024);

View Full Code Here
   1:          serverSocketChannel = ServerSocketChannel.open();
   2:          serverSocketChannel.socket().bind( 
   3:             new InetSocketAddress( 12345 ) );
   4:         ...
   5:                   socketChannel.configureBlocking( false );
   6:                   sockets.add( socketChannel.socket() );
   7:                   counter++;
   8:         ...
   9:    {
  10:       Socket socket;
  11:       SocketChannel socketChannel;
  12:         ...
  13:          socket = ( Socket ) sockets.elementAt( i );
  14:          socketChannel = socket.getChannel();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.nio.channels.SelectableChannel;
   4:         ...
   5:   
   6:   private Socket _s;
   7:   private InputStream _is;
   8:         ...
   9: 
  10:   public QSocketWrapper(Socket s)
  11:   {
  12:         ...
  13:     if (_s != null)
  14:       return _s.getChannel();

View Full Code Here

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.
Usages and Demos :

View More Examples of getInetAddress()
   1:     while (true) {
   2:       Socket socket=null;
   3:       try {
   4:         ...
   5: class Handler implements Runnable{
   6:   private Socket socket;
   7:   public Handler(Socket socket){
   8:         ...
   9:       System.out.println("New connection accepted " +
  10:       socket.getInetAddress() + ":" +socket.getPort());
  11:       BufferedReader br =getReader(socket);

View Full Code Here
   1:         ServerSocket servSock;
   2:         Socket clientSocket;
   3: 
   4:         ...
   5: 
   6:                     Socket clientSocket;
   7:                     synchronized(servSock) {
   8:         ...
   9:                     System.out.println(getName() + " starting, IP=" + 
  10:                         clientSocket.getInetAddress());
  11:                     DataInputStream is = new DataInputStream(
  12:         ...
  13:                 } catch (IOException ex) {
  14:                     System.out.println(getName() + ": IO Error on socket " + ex);

View Full Code Here
   1:     while (true) {
   2:       Socket socket=null;
   3:       try {
   4:         ...
   5:         socket = serverSocket.accept();
   6:       }catch (IOException e) {
   7:         ...
   8:       System.out.println("New connection accepted " +
   9:       socket.getInetAddress() + ":" +socket.getPort());
  10:       BufferedReader br =getReader(socket);

View Full Code Here
   1:     while (true) {
   2:       Socket socket=null;
   3:       try {
   4:         ...
   5:         socket = serverSocket.accept();
   6:         executorService.execute(new Handler(socket));
   7:         ...
   8:       System.out.println("New connection accepted " +
   9:       socket.getInetAddress() + ":" +socket.getPort());
  10:       BufferedReader br =getReader(socket);

View Full Code Here
   1:     serverSocketChannel= ServerSocketChannel.open();
   2:     serverSocketChannel.socket().setReuseAddress(true);
   3:         ...
   4:     serverSocketChannel.socket().bind(new InetSocketAddress(port));
   5:     System.out.println("????????");
   6:         ...
   7:     try {
   8:         Socket socket=socketChannel.socket();
   9:         System.out.println("????????l???4??: " +
  10:         ...
  11:         socket.getInetAddress() + ":" +socket.getPort());

View Full Code Here

getInputStream

public InputStream 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. If the channel is in non-blocking mode then the input stream's read operations will throw an IllegalBlockingModeException.

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 :-

  • The network software may discard bytes that are buffered by the socket. Bytes that aren't discarded by the network software can be read using read.

  • 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.

  • If there are no bytes buffered on the socket, and the socket has not been closed using close, then available will return 0.

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, the socket is not connected, or the socket input has been shutdown using shutdownInput()
Usages and Demos :

View More Examples of getInputStream()
   1:         SocketFactory sf = SSLSocketFactory.getDefault();
   2:         Socket s = sf.createSocket(args[0], Integer.parseInt(args[1]));
   3: 
   4:         ...
   5:                                     new InputStreamReader(
   6:                                         s.getInputStream()));
   7:         PrintWriter pw = new PrintWriter(s.getOutputStream());
   8:         System.out.println("Who is Sylvia?");
   9:         pw.println("Who is Sylvia?");

View Full Code Here
   1: class EchoWorker implements Runnable {
   2:     private Socket _requestSocket;
   3: 
   4:         ...
   5:     public EchoWorker(Socket requestSocket) throws IOException {
   6:     _requestSocket = requestSocket;
   7:         ...
   8:         = new BufferedReader(new InputStreamReader(
   9:                    _requestSocket.getInputStream()));
  10:         responseWriter

View Full Code Here
   1: 
   2:     private Socket sock;
   3:     
   4:         ...
   5:     public SSLSimpleServer(Socket s) {
   6:         sock = s;
   7:         ...
   8:                                     new InputStreamReader(
   9:                                         sock.getInputStream()));
  10:             PrintWriter pw = new PrintWriter(sock.getOutputStream());

View Full Code Here
   1: {
   2:     private Socket socket = null;
   3: 
   4:         ...
   5:     public KKMultiServerThread(Socket socket) {
   6:           super("KKMultiServerThread");
   7:         ...
   8:                BufferedReader in = new BufferedReader( new InputStreamReader(
   9:                             socket.getInputStream()));
  10:            String inputLine, outputLine;

View Full Code Here
   1:         
   2:     Socket clientSocket = null;
   3:     try {
   4:         ...
   5:         new InputStreamReader(
   6:           clientSocket.getInputStream()));
   7:     PrintWriter output = 
   8:       new PrintWriter(clientSocket.getOutputStream());
   9:     System.out.println("Connection established.");

View Full Code Here

getKeepAlive

public boolean getKeepAlive()
            throws SocketException
Tests if SO_KEEPALIVE is enabled.
Returns:
a boolean indicating whether or not SO_KEEPALIVE is enabled.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.3
Usages and Demos :

View More Examples of getKeepAlive()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getKeepAlive();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getKeepAlive();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public boolean getKeepAlive() throws SocketException {
  10:         return socket.getKeepAlive();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public boolean getKeepAlive() throws SocketException {
  10:         return socket.getKeepAlive();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     private final AsyncSocketChannel socketChannel;
   6:     private final Socket socket;
   7: 
   8:         ...
   9:     public boolean getKeepAlive() throws SocketException {
  10:         return socket.getKeepAlive();
  11:     }

View Full Code Here

getLocalAddress

public InetAddress getLocalAddress()
Gets the local address to which the socket is bound.
Returns:
the local address to which the socket is bound or InetAddress.anyLocalAddress() if the socket is not bound yet.
Since:
JDK1.1
Usages and Demos :

View More Examples of getLocalAddress()
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5: 
   6:         Socket so = ((IIOPConnection) getLatestTransportCurentEvent ().transport ()).getSocket ();
   7:         if (so == null) return 0;
   8:         ...
   9: 
  10:         Socket so = ((IIOPConnection) getLatestTransportCurentEvent ().transport ()).getSocket ();
  11:         if (so == null) return null;
  12:         ...
  13:         return so.getLocalAddress().getCanonicalHostName ();

View Full Code Here
   1: 
   2:   protected Socket socket;
   3:   protected boolean blocking;
   4:         ...
   5:   {
   6:     return socket.getInetAddress().getHostName().getBytes();
   7:   }
   8:         ...
   9:   {
  10:     return socket.getLocalAddress().getHostAddress().getBytes();
  11:   }

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public InetAddress getLocalAddress() {
  13:     return origSocket.getLocalAddress();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getLocalAddress();

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.net.UnknownHostException;
   4:         ...
   5: 
   6:     protected Socket socket;
   7: 
   8:         ...
   9:             return new Session(tcpIpProtocolLayer, new IpSessionId(
  10:                     incoming.getLocalAddress().getHostAddress(), incoming
  11:                             .getLocalPort()), new IpSessionId(incoming
  12:         ...
  13:             return new Session(tcpIpProtocolLayer, new IpSessionId(
  14:                     socket.getLocalAddress().getHostAddress(), socket

View Full Code Here

getLocalPort

public int getLocalPort()
Returns the local port to which this socket is bound.
Returns:
the local port number to which this socket is bound or -1 if the socket is not bound yet.
Usages and Demos :

View More Examples of getLocalPort()
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5: public class Streams {
   6:     public final Socket s;
   7:     public final X10InStream in;
   8:         ...
   9:     public final X10OutStream out;
  10:     Streams(Socket sock, X10OutStream output, X10InStream input) {
  11:         s = sock;
  12:         ...
  13:     public String toString() {
  14:         return s.getLocalPort()+" -> "+s.getPort();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5: 
   6:         Socket so = ((IIOPConnection) getLatestTransportCurentEvent ().transport ()).getSocket ();
   7:         if (so == null) return 0;
   8:         ...
   9:         return so.getLocalPort();
  10:     }
  11:         ...
  12: 
  13:         Socket so = ((IIOPConnection) getLatestTransportCurentEvent ().transport ()).getSocket ();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         {
   6:             Socket socket =
   7:                 ((ServerIIOPConnection) transport).getSocket();
   8:         ...
   9:             int localPort = socket.getLocalPort();
  10:             int port = socket.getPort();

View Full Code Here
   1:         this.ssc = ssc;
   2:         port = ssc.socket().getLocalPort();
   3:     }
   4:         ...
   5: 
   6:     public ServerSocket socket() { 
   7:         try {
   8:         ...
   9:             if (ssocket == null) {
  10:                 ServerSocket ss = ssc.socket();
  11:                 ssocket = new ASServerSocket(ss, this);
  12:         ...
  13:         if ( logger.isLoggable(Level.FINE) ) {
  14:              Socket s = sc.socket();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public int getLocalPort() {
  13:     return origSocket.getLocalPort();

View Full Code Here

getLocalSocketAddress

public SocketAddress getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
Returns:
a SocketAddress representing the local endpoint of this socket, or null if it is not bound yet.
Since:
1.4
Usages and Demos :

View More Examples of getLocalSocketAddress()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getLocalSocketAddress();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.InetSocketAddress;
   4:         ...
   5: 
   6:     private Socket sock;
   7:     private BufferedOutputStream os;
   8:         ...
   9: 
  10:     private TrivConnection (Socket sock) throws IOException {
  11:     this.sock = sock;
  12:         ...
  13:     InetSocketAddress addr = (InetSocketAddress)
  14:         sock.getLocalSocketAddress();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public SocketAddress getLocalSocketAddress() {
  13:     return socket.getLocalSocketAddress();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public SocketAddress getLocalSocketAddress() {
  10:         return socket.getLocalSocketAddress();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public SocketAddress getLocalSocketAddress() {
  10:         return socket.getLocalSocketAddress();
  11:     }

View Full Code Here

getOOBInline

public boolean getOOBInline()
            throws SocketException
Tests if OOBINLINE is enabled.
Returns:
a boolean indicating whether or not OOBINLINE is enabled.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.4
Usages and Demos :

View More Examples of getOOBInline()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getOOBInline();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getOOBInline();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public boolean getOOBInline() throws SocketException {
  10:         return socket.getOOBInline();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public boolean getOOBInline() throws SocketException {
  10:         return socket.getOOBInline();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     private final AsyncSocketChannel socketChannel;
   6:     private final Socket socket;
   7: 
   8:         ...
   9:     public boolean getOOBInline() throws SocketException {
  10:         return socket.getOOBInline();
  11:     }

View Full Code Here

getOutputStream

public OutputStream 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. If the channel is in non-blocking mode then the output stream's write operations will throw an IllegalBlockingModeException.

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.
Usages and Demos :

View More Examples of getOutputStream()
   1: 
   2:     Socket connection = null;
   3:     try {
   4:         ...
   5:       connection = new Socket(hostname, DEFAULT_PORT);
   6:       Writer out = new OutputStreamWriter(
   7:         ...
   8:        connection.getOutputStream(), "8859_1"
   9:       );

View Full Code Here
   1: 
   2:         Socket clientSocket = null;
   3:         try {
   4:         ...
   5:                           new BufferedOutputStream(
   6:                   clientSocket.getOutputStream(), 1024), false);
   7:         DataInputStream in = new DataInputStream(
   8:                              new BufferedInputStream(
   9:                      clientSocket.getInputStream()));

View Full Code Here
   1:     try {
   2:       Socket soket = serverSoket.accept();
   3:       try {
   4:         ...
   5:               new OutputStreamWriter(
   6:                 soket.getOutputStream())),true);
   7:         while (true) {  
   8:           String str = vstup.readLine();
   9:           if (str.equals("END")) break;

View Full Code Here
   1:     protected int port = NETLOG_PORT;
   2:     protected Socket sock = null;
   3:     protected PrintWriter os;
   4:         ...
   5:         port = prtNum;
   6:         sock = new Socket(host, prtNum);
   7:         os = new PrintWriter(
   8:         ...
   9:             new OutputStreamWriter(
  10:                 sock.getOutputStream(), "8859_1"), true);
  11:     }

View Full Code Here
   1:     System.out.println("adresa = " + adresa);
   2:     Socket soket = 
   3:         ...
   4:       new Socket(adresa, JabberServer.PORT);
   5:     try {
   6:         ...
   7:             new OutputStreamWriter(
   8:               soket.getOutputStream())),true);
   9:       for(int i = 0; i < 10; i ++) {

View Full Code Here

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.
Usages and Demos :

View More Examples of getPort()
   1: 
   2: import java.net.Socket;
   3: 
   4:         ...
   5: public class Streams {
   6:     public final Socket s;
   7:     public final X10InStream in;
   8:         ...
   9:     public final X10OutStream out;
  10:     Streams(Socket sock, X10OutStream output, X10InStream input) {
  11:         s = sock;
  12:         ...
  13:     public String toString() {
  14:         return s.getLocalPort()+" -> "+s.getPort();

View Full Code Here
   1:     while (true) {
   2:       Socket socket=null;
   3:       try {
   4:         ...
   5: class Handler implements Runnable{
   6:   private Socket socket;
   7:   public Handler(Socket socket){
   8:         ...
   9:       System.out.println("New connection accepted " +
  10:       socket.getInetAddress() + ":" +socket.getPort());
  11:       BufferedReader br =getReader(socket);

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:     private DestAddress remoteAddress;
   6:     private Socket socket;
   7:     
   8:         ...
   9:             remoteAddress = new DefaultDestAddress(
  10:                 socket.getInetAddress().getHostAddress(), socket.getPort() );
  11:         }

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:     private DestAddress remoteAddress;
   6:     private Socket socket;
   7:     
   8:         ...
   9:             remoteAddress = new DefaultDestAddress(
  10:                 socket.getInetAddress().getHostAddress(), socket.getPort() );
  11:         }

View Full Code Here
   1:     while (true) {
   2:       Socket socket=null;
   3:       try {
   4:         ...
   5:         socket = serverSocket.accept();
   6:       }catch (IOException e) {
   7:         ...
   8:       System.out.println("New connection accepted " +
   9:       socket.getInetAddress() + ":" +socket.getPort());
  10:       BufferedReader br =getReader(socket);

View Full Code Here

getReceiveBufferSize

public int getReceiveBufferSize()
            throws SocketException
Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.
Returns:
the value of the SO_RCVBUF option for this Socket.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.2
Usages and Demos :

View More Examples of getReceiveBufferSize()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getReceiveBufferSize();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getReceiveBufferSize();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public int getReceiveBufferSize() throws SocketException {
  10:         return socket.getReceiveBufferSize();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public int getReceiveBufferSize() throws SocketException {
  10:         return socket.getReceiveBufferSize();
  11:     }

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     public Socket createSocket(AEDTO localAE, AEDTO remoteAE)
   7:             throws IOException {
   8:         ...
   9:         String[] cipherSuites = remoteAE.getCipherSuites();
  10:         Socket s = (cipherSuites == null || cipherSuites.length == 0) 
  11:                 ? socketFactory(cipherSuites).createSocket()
  12:         ...
  13:     private void initReceiveBufferSize(Socket s) throws SocketException {
  14:         int tmp = s.getReceiveBufferSize();

View Full Code Here

getRemoteSocketAddress

public SocketAddress getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
Returns:
a SocketAddress reprensenting the remote endpoint of this socket, or null if it is not connected yet.
Since:
1.4
Usages and Demos :

View More Examples of getRemoteSocketAddress()
   1:         try {
   2:         Socket newSock = s.accept();
   3:         newSock.setTcpNoDelay(true);
   4:         ...
   5:         System.out.println("CricketDaemon accepting new connection from "+
   6:                    newSock.getRemoteSocketAddress());
   7:         scl.registerClient(newSock); 
   8:         }
   9:         catch (IOException io) {

View Full Code Here
   1: import java.net.Socket;
   2: import java.net.InetSocketAddress;
   3:         ...
   4: public class SocketUtil {
   5:     public static void printSocketInfo(Socket socket, String dir) {
   6:         try {
   7:         ...
   8:             InetSocketAddress localAddr = (InetSocketAddress)socket.getLocalSocketAddress();
   9:             InetSocketAddress remoteAddr = (InetSocketAddress)socket.getRemoteSocketAddress();
  10:             String localAddrId = localAddr.getHostName() + ":" + localAddr.getPort();

View Full Code Here
   1: import java.net.MalformedURLException;
   2: import java.net.Socket;
   3: import java.net.ServerSocket;
   4:         ...
   5:             while (true) {
   6:                 Socket sock = srvSocket.accept();
   7:                 BaseConnection conn =
   8:         ...
   9:                 InetSocketAddress key = (InetSocketAddress)
  10:                 sock.getRemoteSocketAddress();
  11:                 if (log.isDebugEnabled()) {

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getRemoteSocketAddress();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.InetSocketAddress;
   4:         ...
   5: 
   6:     private Socket sock;
   7:     private BufferedOutputStream os;
   8:         ...
   9: 
  10:     private TrivConnection (Socket sock) throws IOException {
  11:     this.sock = sock;
  12:         ...
  13:     InetSocketAddress addr = (InetSocketAddress)
  14:         sock.getRemoteSocketAddress();

View Full Code Here

getReuseAddress

public boolean getReuseAddress()
            throws SocketException
Tests if SO_REUSEADDR is enabled.
Returns:
a boolean indicating whether or not SO_REUSEADDR is enabled.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.4
Usages and Demos :

View More Examples of getReuseAddress()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getReuseAddress();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getReuseAddress();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public boolean getReuseAddress() throws SocketException {
  10:         return socket.getReuseAddress();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public boolean getReuseAddress() throws SocketException {
  10:         return socket.getReuseAddress();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     private final AsyncSocketChannel socketChannel;
   6:     private final Socket socket;
   7: 
   8:         ...
   9:     public boolean getReuseAddress() throws SocketException {
  10:         return socket.getReuseAddress();
  11:     }

View Full Code Here

getSendBufferSize

public int getSendBufferSize()
            throws SocketException
Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
Returns:
the value of the SO_SNDBUF option for this Socket.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.2
Usages and Demos :

View More Examples of getSendBufferSize()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getSendBufferSize();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getSendBufferSize();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public int getSendBufferSize() throws SocketException {
  10:         return socket.getSendBufferSize();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public int getSendBufferSize() throws SocketException {
  10:         return socket.getSendBufferSize();
  11:     }

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     public Socket createSocket(AEDTO localAE, AEDTO remoteAE)
   7:             throws IOException {
   8:         ...
   9:         String[] cipherSuites = remoteAE.getCipherSuites();
  10:         Socket s = (cipherSuites == null || cipherSuites.length == 0) 
  11:                 ? socketFactory(cipherSuites).createSocket()
  12:         ...
  13:     private void initSendBufferSize(Socket s) throws SocketException {
  14:         int tmp = s.getSendBufferSize();

View Full Code Here

getSoLinger

public int getSoLinger()
            throws SocketException
Returns setting for SO_LINGER. -1 returns implies that the option is disabled. The setting only affects socket close.
Returns:
the setting for SO_LINGER.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK1.1
Usages and Demos :

View More Examples of getSoLinger()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public int getSoLinger() throws SocketException {
  13:     return origSocket.getSoLinger();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getSoLinger();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getSoLinger();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public int getSoLinger() throws SocketException {
  10:         return socket.getSoLinger();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public int getSoLinger() throws SocketException {
  10:         return socket.getSoLinger();
  11:     }

View Full Code Here

getSoTimeout

public int getSoTimeout()
            throws SocketException
Returns setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity).
Returns:
the setting for SO_TIMEOUT
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK1.1
Usages and Demos :

View More Examples of getSoTimeout()
   1: {
   2:     protected Socket socket;
   3: 
   4:         ...
   5:     {
   6:         if (socket != null)
   7:         {
   8:         ...
   9:         {
  10:             return socket.getSoTimeout();
  11:         }

View Full Code Here
   1:     protected InputStream in = null;
   2:     protected Socket sc = null;
   3:     private HostPortEpid epid = null;
   4:         ...
   5: 
   6:     public TcpSocketChannel_J2SE(Socket s) {
   7:         try {
   8:         ...
   9:             int port = ((HostPortEpid)epi).getPortNumber();
  10:             sc = new Socket(host, port);
  11:             out = sc.getOutputStream();
  12:         ...
  13:         try {
  14:             t = sc.getSoTimeout();

View Full Code Here
   1:     protected BufferedInputStream in = null;
   2:     protected Socket sc = null;
   3: 
   4:         ...
   5: 
   6:     public TcpBufferedSocketChannel_J2SE(Socket s) {
   7:         try {
   8:         ...
   9:             int port = ((HostPortEpid)epi).getPortNumber();
  10:             sc = new Socket(host, port);
  11:             out = new BufferedOutputStream(sc.getOutputStream());
  12:         ...
  13:         try {
  14:             t = sc.getSoTimeout();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public synchronized int getSoTimeout() throws SocketException {
  13:     return origSocket.getSoTimeout();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getSoTimeout();

View Full Code Here

getTcpNoDelay

public boolean getTcpNoDelay()
            throws SocketException
Tests if TCP_NODELAY is enabled.
Returns:
a boolean indicating whether or not TCP_NODELAY is enabled.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK1.1
Usages and Demos :

View More Examples of getTcpNoDelay()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public boolean getTcpNoDelay() throws SocketException {
  13:     return origSocket.getTcpNoDelay();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getTcpNoDelay();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getTcpNoDelay();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public boolean getTcpNoDelay() throws SocketException {
  10:         return socket.getTcpNoDelay();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public boolean getTcpNoDelay() throws SocketException {
  10:         return socket.getTcpNoDelay();
  11:     }

View Full Code Here

getTrafficClass

public int getTrafficClass()
            throws SocketException
Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

Returns:
the traffic class or type-of-service already set
Throws:
SocketException - if there is an error obtaining the traffic class or type-of-service value.
Since:
1.4
Usages and Demos :

View More Examples of getTrafficClass()
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.getTrafficClass();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     return socket.getTrafficClass();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public int getTrafficClass() throws SocketException {
  10:         return socket.getTrafficClass();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public int getTrafficClass() throws SocketException {
  10:         return socket.getTrafficClass();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     private final AsyncSocketChannel socketChannel;
   6:     private final Socket socket;
   7: 
   8:         ...
   9:     public int getTrafficClass() throws SocketException {
  10:         return socket.getTrafficClass();
  11:     }

View Full Code Here

isBound

public boolean isBound()
Returns the binding state of the socket.
Returns:
true if the socket successfuly bound to an address
Since:
1.4
Usages and Demos :

View More Examples of isBound()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:   
   6:   public static void put_socket(Object key, Socket s)
   7:   {
   8:         ...
   9:     Map.Entry e;
  10:     Socket sx;
  11:     
  12:         ...
  13:   {
  14:     return (s.isClosed() || !s.isBound() || !s.isConnected() ||

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.isBound();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public boolean isBound() {
  13:     return socket.isBound();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public boolean isBound() {
  10:         return socket.isBound();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public boolean isBound() {
  10:         return socket.isBound();
  11:     }

View Full Code Here

isClosed

public boolean isClosed()
Returns the closed state of the socket.
Returns:
true if the socket has been closed
Since:
1.4
See Also:
close()
Usages and Demos :

View More Examples of isClosed()
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.text.DateFormat;
   4:         ...
   5:                 try {
   6:                     Socket socket = server.accept();
   7: 
   8:         ...
   9:                             new OutputStreamWriter(socket.getOutputStream()));
  10:                     while (!socket.isClosed()) {
  11:                         String current = updateCurrentXML();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:   
   6:   public static void put_socket(Object key, Socket s)
   7:   {
   8:         ...
   9:     Map.Entry e;
  10:     Socket sx;
  11:     
  12:         ...
  13:   {
  14:     return (s.isClosed() || !s.isBound() || !s.isConnected() ||

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: {
   6:     Socket _socket;
   7:     InetSocketAddress _local;
   8:         ...
   9: 
  10:     public SocketEndPoint(Socket socket)
  11:         throws IOException    
  12:         ...
  13:     {
  14:         return _socket==null || _socket.isClosed() || _socket.isInputShutdown() || _socket.isOutputShutdown();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.isClosed();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public boolean isClosed() {
  13:     return socket.isClosed();

View Full Code Here

isConnected

public boolean isConnected()
Returns the connection state of the socket.
Returns:
true if the socket successfuly connected to a server
Since:
1.4
Usages and Demos :

View More Examples of isConnected()
   1: public class CommunicationThread extends Thread {
   2:     private Socket socket = null;
   3:     
   4:         ...
   5:     
   6:     public CommunicationThread(Socket socket) {
   7:     super("CommunicationThread");
   8:         ...
   9:            
  10:             while(socket.isConnected())
  11:             {           

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: 
   6:     private Socket mySocket;
   7:     private OutputStream myOutputStream;
   8:         ...
   9:     public boolean isConnected(SVNRepositoryImpl repos) throws SVNException {
  10:         return mySocket != null && mySocket.isConnected();
  11:     }

View Full Code Here
   1: import java.io.UnsupportedEncodingException;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: 
   6:     private Socket socket;
   7: 
   8:         ...
   9:     public boolean isConnected() {
  10:         return (socket != null) ? socket.isConnected() : false;
  11:     }

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:   
   6:   public static void put_socket(Object key, Socket s)
   7:   {
   8:         ...
   9:     Map.Entry e;
  10:     Socket sx;
  11:     
  12:         ...
  13:   {
  14:     return (s.isClosed() || !s.isBound() || !s.isConnected() ||

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.isConnected();

View Full Code Here

isInputShutdown

public boolean isInputShutdown()
Returns whether the read-half of the socket connection is closed.
Returns:
true if the input of the socket has been shutdown
Since:
1.4
Usages and Demos :

View More Examples of isInputShutdown()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:   
   6:   public static void put_socket(Object key, Socket s)
   7:   {
   8:         ...
   9:     Map.Entry e;
  10:     Socket sx;
  11:     
  12:         ...
  13:     return (s.isClosed() || !s.isBound() || !s.isConnected() ||
  14:         s.isInputShutdown() || s.isOutputShutdown());

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: {
   6:     Socket _socket;
   7:     InetSocketAddress _local;
   8:         ...
   9: 
  10:     public SocketEndPoint(Socket socket)
  11:         throws IOException    
  12:         ...
  13:     {
  14:         return _socket==null || _socket.isClosed() || _socket.isInputShutdown() || _socket.isOutputShutdown();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.isInputShutdown();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public boolean isInputShutdown() {
  13:     return socket.isInputShutdown();

View Full Code Here
   1: import java.io.InputStream;
   2: import java.net.Socket;
   3: import java.net.UnknownHostException;
   4:         ...
   5: 
   6:     private Socket socket = null;
   7: 
   8:         ...
   9:             || !socket.isConnected()
  10:             || socket.isInputShutdown()
  11:             || socket.isOutputShutdown()

View Full Code Here

isOutputShutdown

public boolean isOutputShutdown()
Returns whether the write-half of the socket connection is closed.
Returns:
true if the output of the socket has been shutdown
Since:
1.4
Usages and Demos :

View More Examples of isOutputShutdown()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5:   
   6:   public static void put_socket(Object key, Socket s)
   7:   {
   8:         ...
   9:     Map.Entry e;
  10:     Socket sx;
  11:     
  12:         ...
  13:     return (s.isClosed() || !s.isBound() || !s.isConnected() ||
  14:         s.isInputShutdown() || s.isOutputShutdown());

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: {
   6:     Socket _socket;
   7:     InetSocketAddress _local;
   8:         ...
   9: 
  10:     public SocketEndPoint(Socket socket)
  11:         throws IOException    
  12:         ...
  13:     {
  14:         return _socket==null || _socket.isClosed() || _socket.isInputShutdown() || _socket.isOutputShutdown();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     return filling.isOutputShutdown();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public boolean isOutputShutdown() {
  13:     return socket.isOutputShutdown();

View Full Code Here
   1: import java.net.InetSocketAddress;
   2: import java.net.Socket;
   3: import java.net.SocketTimeoutException;
   4:         ...
   5:     
   6:     private    Socket                mServerSocket = null;
   7:     private BufferedReader        mInput = null;
   8:         ...
   9:     
  10:     public Socket getServerSocket()
  11:     {
  12:         ...
  13:             !mServerSocket.isConnected() ||
  14:             mServerSocket.isOutputShutdown() ||

View Full Code Here

sendUrgentData

public void sendUrgentData(int data)
            throws IOException
Send one byte of urgent data on the socket. The byte to be sent is the lowest eight bits of the data parameter. The urgent byte is sent after any preceding writes to the socket OutputStream and before any future writes to the OutputStream.
Parameters:
data - The byte of data to send
Throws:
IOException - if there is an error sending the data.
Since:
1.4
Usages and Demos :

View More Examples of sendUrgentData(int data)
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.sendUrgentData(data);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.sendUrgentData(data);

View Full Code Here

setKeepAlive

public void setKeepAlive(boolean on)
            throws SocketException
Enable/disable SO_KEEPALIVE.
Parameters:
on - whether or not to have socket keep alive turned on.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.3
Usages and Demos :

View More Examples of setKeepAlive(boolean on)
   1: 
   2:       Socket echoSocket = null;
   3:       PrintWriter out = null;
   4:         ...
   5:       try {
   6:          echoSocket = new Socket(proxyHost, port);
   7:          echoSocket.setTcpNoDelay(true);
   8:          echoSocket.setSoLinger(true, 2000);
   9:          System.out.println("\n*** Connected to proxy=" + proxyHost + " on proxyPort=" + port + " accessing " + destinationUrl);

View Full Code Here
   1: package org.jboss.remoting.transport.socket;
   2: 
   3:         ...
   4: import java.net.InetAddress;
   5: import java.net.Socket;
   6: import java.util.ArrayList;
   7:         ...
   8:                 {
   9:                     Socket s = (Socket) available.get(x);
  10:                     try
  11:         ...
  12:             };
  13:             s.setKeepAlive(true);

View Full Code Here
   1: 
   2:     private Socket socket;
   3:     protected InputStream socketIn;
   4:         ...
   5:             try {
   6:                 socket = new Socket(address, port);
   7:                 monitor.worked(90);
   8:         ...
   9:             try {
  10:                 socket.setKeepAlive(true);
  11:                 setTimeoutEnabled(true);

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setKeepAlive( on );

View Full Code Here
   1: import java.io.*;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     private Socket socket;
   7:     private InputStream socketIn;
   8:         ...
   9:                 try {
  10:                     socket.setKeepAlive(false);
  11:                 } catch (SocketException e) {

View Full Code Here

setOOBInline

public void setOOBInline(boolean on)
            throws SocketException
Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded. If the user wishes to receive urgent data, then this option must be enabled. When enabled, urgent data is received inline with normal data.

Note, only limited support is provided for handling incoming urgent data. In particular, no notification of incoming urgent data is provided and there is no capability to distinguish between normal data and urgent data unless provided by a higher level protocol.

Parameters:
on - true to enable OOBINLINE, false to disable.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.4
Usages and Demos :

View More Examples of setOOBInline(boolean on)
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setOOBInline(on);

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         while ( doListen() ) {
   6:             Socket socket = null;
   7:             if ( getTaskPool().available() < 1 ) {
   8:         ...
   9:             socket.setKeepAlive(getSoKeepAlive());
  10:             socket.setOOBInline(getOoBInline());
  11:             socket.setReuseAddress(getSoReuseAddress());

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.setOOBInline(on);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public void setOOBInline(boolean on) throws SocketException {
  10:         socket.setOOBInline(on);
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public void setOOBInline(boolean on) throws SocketException {
  10:         socket.setOOBInline(on);
  11:     }

View Full Code Here

setPerformancePreferences

public void setPerformancePreferences(int connectionTime,
                                      int latency,
                                      int bandwidth)
Sets performance preferences for this socket.

Sockets use the TCP/IP protocol by default. Some implementations may offer alternative protocols which have different performance characteristics than TCP/IP. This method allows the application to express its own preferences as to how these tradeoffs should be made when the implementation chooses from the available protocols.

Performance preferences are described by three integers whose values indicate the relative importance of short connection time, low latency, and high bandwidth. The absolute values of the integers are irrelevant; in order to choose a protocol the values are simply compared, with larger values indicating stronger preferences. Negative values represent a lower priority than positive values. If the application prefers short connection time over both low latency and high bandwidth, for example, then it could invoke this method with the values (1, 0, 0). If the application prefers high bandwidth above low latency, and low latency above short connection time, then it could invoke this method with the values (0, 1, 2).

Invoking this method after this socket has been connected will have no effect.

Parameters:
connectionTime - An int expressing the relative importance of a short connection time
latency - An int expressing the relative importance of low latency
bandwidth - An int expressing the relative importance of high bandwidth
Since:
1.5
Usages and Demos :

View More Examples of setPerformancePreferences(int connectionTime,int latency,int bandwidth)
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     public void setProperties(Socket socket) throws SocketException{
   7:         socket.setReceiveBufferSize(rxBufSize);
   8:         ...
   9:         socket.setKeepAlive(soKeepAlive);
  10:         socket.setPerformancePreferences(performanceConnectionTime,performanceLatency,performanceBandwidth);
  11:         socket.setReuseAddress(soReuseAddress);

View Full Code Here

setReceiveBufferSize

public void setReceiveBufferSize(int size)
            throws SocketException
Sets the SO_RCVBUF option to the specified value for this Socket. The SO_RCVBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers.

Increasing the receive buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data.

Because SO_RCVBUF is a hint, applications that want to verify what size the buffers were set to should call getReceiveBufferSize().

The value of SO_RCVBUF is also used to set the TCP receive window that is advertized to the remote peer. Generally, the window size can be modified at any time when a socket is connected. However, if a receive window larger than 64K is required then this must be requested before the socket is connected to the remote peer. There are two cases to be aware of:

  1. For sockets accepted from a ServerSocket, this must be done by calling ServerSocket.setReceiveBufferSize(int) before the ServerSocket is bound to a local address.

  2. For client sockets, setReceiveBufferSize() must be called before connecting the socket to its remote peer.

Parameters:
size - the size to which to set the receive buffer size. This value must be greater than 0.
Throws:
IllegalArgumentException - if the value is 0 or is negative.
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
1.2
Usages and Demos :

View More Examples of setReceiveBufferSize(int size)
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5:         System.out.println("Listening on 9999");
   6:         Socket socket = srvSocket.accept();
   7:         ...
   8:         socket.setReceiveBufferSize(43800);
   9:         InputStream in = socket.getInputStream();

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.io.IOException;
   4:         ...
   5: public class LargeStateClient {
   6:     Socket       sock;
   7:     InetAddress  bind_addr, host_addr;
   8:         ...
   9:         this.host_addr=InetAddress.getByName(host_addr);
  10:         sock=new Socket(this.host_addr, 7500, this.bind_addr, 0);
  11:         ...
  12:         sock.setReceiveBufferSize(chunk);

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5:         System.out.println("Listening on 9999");
   6:         Socket socket = srvSocket.accept();
   7:         ...
   8:         socket.setReceiveBufferSize(size);
   9:         InputStream in = socket.getInputStream();

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5:         System.out.println("Listening on 9999");
   6:         Socket socket = srvSocket.accept();
   7:         ...
   8:         socket.setReceiveBufferSize(size);
   9:         InputStream in = socket.getInputStream();

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setReceiveBufferSize( size );

View Full Code Here

setReuseAddress

public void setReuseAddress(boolean on)
            throws SocketException
Enable/disable the SO_REUSEADDR socket option.

When a TCP connection is closed the connection may remain in a timeout state for a period of time after the connection is closed (typically known as the TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port.

Enabling SO_REUSEADDR prior to binding the socket using bind(SocketAddress) allows the socket to be bound even though a previous connection is in a timeout state.

When a Socket is created the initial setting of SO_REUSEADDR is disabled.

The behaviour when SO_REUSEADDR is enabled or disabled after a socket is bound (See isBound()) is not defined.

Parameters:
on - whether to enable or disable the socket option
Throws:
SocketException - if an error occurs enabling or disabling the SO_RESUEADDR socket option, or the socket is closed.
Since:
1.4
Usages and Demos :

View More Examples of setReuseAddress(boolean on)
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setReuseAddress( on );

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         while ( doListen() ) {
   6:             Socket socket = null;
   7:             if ( getTaskPool().available() < 1 ) {
   8:         ...
   9:             socket.setOOBInline(getOoBInline());
  10:             socket.setReuseAddress(getSoReuseAddress());
  11:             socket.setSoLinger(getSoLingerOn(),getSoLingerTime());

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.setReuseAddress(on);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public void setReuseAddress(boolean on) throws SocketException {
  10:         socket.setReuseAddress(on);
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public void setReuseAddress(boolean on) throws SocketException {
  10:         socket.setReuseAddress(on);
  11:     }

View Full Code Here

setSendBufferSize

public void setSendBufferSize(int size)
            throws SocketException
Sets the SO_SNDBUF option to the specified value for this Socket. The SO_SNDBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers.

Because SO_SNDBUF is a hint, applications that want to verify what size the buffers were set to should call getSendBufferSize().

Parameters:
size - the size to which to set the send buffer size. This value must be greater than 0.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
IllegalArgumentException - if the value is 0 or is negative.
Since:
1.2
Usages and Demos :

View More Examples of setSendBufferSize(int size)
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:             System.out.println("-- waiting for clients to connect");
   6:             Socket sock=srv_sock.accept();
   7:         ...
   8:             sock.setSendBufferSize(chunk_size);
   9:             sendLargeState(sock);
  10:         ...
  11: 
  12:     private void sendLargeState(Socket sock) throws IOException {

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setSendBufferSize( size );

View Full Code Here
   1: import java.io.*;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     private Socket socket;
   7:     private InputStream socketIn;
   8:         ...
   9:             socket.shutdownInput();
  10:             socket.setSendBufferSize(FtpPlugin.getDefault().getSendBufferSize());
  11:             socketOut = new PollingOutputStream(new TimeoutOutputStream(socket.getOutputStream(),

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         while ( doListen() ) {
   6:             Socket socket = null;
   7:             if ( getTaskPool().available() < 1 ) {
   8:         ...
   9:             socket.setReceiveBufferSize(getRxBufSize());
  10:             socket.setSendBufferSize(getRxBufSize());
  11:             socket.setTcpNoDelay(getTcpNoDelay());

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.setSendBufferSize(size);

View Full Code Here

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
            throws SocketException
Enable/disable SO_LINGER with the specified linger time in seconds. The maximum timeout value is platform specific. The setting only affects socket close.
Parameters:
on - whether or not to linger on.
linger - how long to linger for, if on is true.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
IllegalArgumentException - if the linger value is negative.
Since:
JDK1.1
See Also:
getSoLinger()
Usages and Demos :

View More Examples of setSoLinger(boolean on,int linger)
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:                 int val) throws SocketException {
  13:     origSocket.setSoLinger(on, val);

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setSoLinger(on, linger);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.setSoLinger(flag, linger);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public void setSoLinger(boolean on, int linger) throws SocketException {
  10:         socket.setSoLinger(on, linger);
  11:     }

View Full Code Here
   1:     int CommandIdGenerator = 1;
   2:     Socket fSocket;
   3:     Thread fThread;
   4:         ...
   5:         
   6:         fSocket = new Socket(host, port);
   7:                 
   8:         ...
   9:         else {
  10:             fThread = new Thread(this, "Socket Listener");
  11:             fThread.start();
  12:         ...
  13:         try {
  14:             fSocket.setSoLinger(false, 0);

View Full Code Here

setSoTimeout

public void setSoTimeout(int timeout)
            throws SocketException
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.
Parameters:
timeout - the specified timeout, in milliseconds.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK 1.1
Usages and Demos :

View More Examples of setSoTimeout(int timeout)
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:   private Domain _domain;
   6:   private Socket _socket;
   7: 
   8:         ...
   9:   public SocketInputOutput(Env env, Socket socket, Domain domain)
  10:   {
  11:         ...
  12:       if (_socket != null)
  13:     _socket.setSoTimeout((int) timeout);

View Full Code Here
   1:     
   2:     Socket socket;
   3:     
   4:         ...
   5:     
   6:     public PlayerAgent(Socket socket, int playerIndex) throws SocketException, IOException{
   7:         this.socket = socket;
   8:         ...
   9:             long timeUsed,currentTime;
  10:             socket.setSoTimeout(120000);
  11:             os.write(messageData);
  12:         ...
  13:         do{
  14:             socket.setSoTimeout((int)(timeRemaining-timeUsed));

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: class TcpStream extends StreamImpl {
   6:   private Socket _s;
   7:   private InputStream _is;
   8:         ...
   9: 
  10:     _s = new Socket();
  11:     
  12:         ...
  13: 
  14:     _s.setSoTimeout((int) timeout);

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:     private static final Log log = LogFactory.getLog(SlowConsumerTest.class);
   6:     private Socket stompSocket;
   7:     private ByteArrayOutputStream inputBuffer;
   8:         ...
   9:     public String receiveFrame(long timeOut) throws Exception {
  10:         stompSocket.setSoTimeout((int) timeOut);
  11:         InputStream is = stompSocket.getInputStream();
  12:         ...
  13:             if (c < 0) {
  14:                 throw new IOException("socket closed.");

View Full Code Here
   1: import java.net.InetAddress ;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:     private int port;
   6:     private Socket sc = null;
   7:     private boolean isSocketConnected = false;
   8:         ...
   9:     {
  10:         sc = new Socket(getAddress(),getPort());
  11:         ...
  12:         sc.setSoTimeout((int)ackTimeout);

View Full Code Here

setSocketImplFactory

public static void setSocketImplFactory(SocketImplFactory fac)
            throws IOException
Sets the client socket implementation factory for the application. The factory can be specified only once.

When an application creates a new client socket, the socket implementation factory's createSocketImpl method is called to create the actual socket implementation.

Passing null to the method is a no-op unless the factory was already set.

If there is a security manager, this method first calls the security manager's checkSetFactory method to ensure the operation is allowed. This could result in a SecurityException.

Parameters:
fac - the desired factory.
Throws:
IOException - if an I/O error occurs when setting the socket factory.
SecurityException - if a security manager exists and its checkSetFactory method doesn't allow the operation.
Usages and Demos :

View More Examples of setSocketImplFactory(SocketImplFactory fac)
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     Socket.setSocketImplFactory( fac );

View Full Code Here

setTcpNoDelay

public void setTcpNoDelay(boolean on)
            throws SocketException
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
Parameters:
on - true to enable TCP_NODELAY, false to disable.
Throws:
SocketException - if there is an error in the underlying protocol, such as a TCP error.
Since:
JDK1.1
Usages and Demos :

View More Examples of setTcpNoDelay(boolean on)
   1:         try {
   2:         Socket newSock = s.accept();
   3:         ...
   4:         newSock.setTcpNoDelay(true);
   5:         System.out.println("CricketDaemon accepting new connection from "+
   6:                    newSock.getRemoteSocketAddress());
   7:         scl.registerClient(newSock); 

View Full Code Here
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:     public
   6:     Runnable accept(Server server, Socket socket) throws IOException
   7:     {
   8:         ...
   9:         socket.setTcpNoDelay(on);
  10:         return base.accept(server, socket);

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.util.ArrayList;
   4:         ...
   5:                 
   6:                 Socket client = msgServer.accept();                
   7:                 
   8:                 if(Report.should_report("cluster", Debug.comm))
   9:                     Report.report(Debug.comm, "Accepted a connection from: "+client.getInetAddress());

View Full Code Here
   1: 
   2:       Socket echoSocket = null;
   3:       PrintWriter out = null;
   4:         ...
   5:       try {
   6:          echoSocket = new Socket(proxyHost, port);
   7:         ...
   8:          echoSocket.setTcpNoDelay(true);
   9:          echoSocket.setSoLinger(true, 2000);

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: import java.nio.channels.Selector;
   4:         ...
   5: 
   6:     Socket socket = _ss.accept();
   7: 
   8:         ...
   9:     if (_tcpNoDelay)
  10:       socket.setTcpNoDelay(true);

View Full Code Here

setTrafficClass

public void setTrafficClass(int tc)
            throws SocketException
Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. As the underlying network implementation may ignore this value applications should consider it a hint.

The tc must be in the range 0 <= tc <= 255 or an IllegalArgumentException will be thrown.

Notes:

for Internet Protocol v4 the value consists of an octet with precedence and TOS fields as detailed in RFC 1349. The TOS field is bitset created by bitwise-or'ing values such the following :-

  • IPTOS_LOWCOST (0x02)
  • IPTOS_RELIABILITY (0x04)
  • IPTOS_THROUGHPUT (0x08)
  • IPTOS_LOWDELAY (0x10)
The last low order bit is always ignored as this corresponds to the MBZ (must be zero) bit.

Setting bits in the precedence field may result in a SocketException indicating that the operation is not permitted.

for Internet Protocol v6 tc is the value that would be placed into the sin6_flowinfo field of the IP header.

Parameters:
tc - an int value for the bitset.
Throws:
SocketException - if there is an error setting the traffic class or type-of-service
Since:
1.4
Usages and Demos :

View More Examples of setTrafficClass(int tc)
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.setTrafficClass( tc );

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         while ( doListen() ) {
   6:             Socket socket = null;
   7:             if ( getTaskPool().available() < 1 ) {
   8:         ...
   9:             socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
  10:             socket.setTrafficClass(getSoTrafficClass());
  11:             socket.setSoTimeout(getTimeout());

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.setTrafficClass(tc);

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5:     protected final SocketChannel socketChannel;
   6:     protected final Socket socket;
   7:     private final boolean useDirect;
   8:         ...
   9:     public void setTrafficClass(int tc) throws SocketException {
  10:         socket.setTrafficClass(tc);
  11:     }    

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6:     private final Socket socket;
   7:     private final OutputStream out;
   8:         ...
   9:     public void setTrafficClass(int tc) throws SocketException {
  10:         socket.setTrafficClass(tc);
  11:     }

View Full Code Here

shutdownInput

public void shutdownInput()
            throws IOException
Places the input stream for this socket at "end of stream". Any data sent to the input stream side of the socket is acknowledged and then silently discarded.

If you read from a socket input stream after invoking shutdownInput() on the socket, the stream will return EOF.

Throws:
IOException - if an I/O error occurs when shutting down this socket.
Since:
1.3
Usages and Demos :

View More Examples of shutdownInput()
   1:    protected ServerSocket server_socket;
   2:    protected Socket client_socket;
   3:    protected boolean blocking;
   4:         ...
   5:       throws IOException, SecurityException {
   6:       final Socket accepted_socket = JDK.accept(server_socket, true);
   7:       if( accepted_socket == null )
   8:         ...
   9:         client_socket.shutdownOutput();
  10:         client_socket.shutdownInput();
  11:      } catch (Exception _) {
  12:         ...
  13:    public void write( final output_port  p ) {
  14:       p.write( "#<socket:" + server_socket.getInetAddress() 

View Full Code Here
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:     protected void finishConnection(){
   6:         Socket socket = processorTask.getSocket();
   7:         
   8:         ...
   9:                 if (!socket.isInputShutdown()){
  10:                     socket.shutdownInput();
  11:                 }

View Full Code Here
   1: import java.net.*;
   2: import java.net.Socket;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6: public class SocketWrapper extends Socket
   7: {
   8:         ...
   9:   private String id;
  10:   private Socket filling;
  11:   
  12:         ...
  13:   {
  14:     filling.shutdownInput();

View Full Code Here
   1: import java.io.*;
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6:     private Socket socket;
   7:     private InputStream socketIn;
   8:         ...
   9:         try {
  10:             socket.shutdownInput();
  11:             socket.setSendBufferSize(FtpPlugin.getDefault().getSendBufferSize());

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     {
  13:     socket.shutdownInput();

View Full Code Here

shutdownOutput

public void shutdownOutput()
            throws IOException
Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.
Throws:
IOException - if an I/O error occurs when shutting down this socket.
Since:
1.3
Usages and Demos :

View More Examples of shutdownOutput()
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: 
   6:             Socket s=new Socket(InetAddress.getByName("127.0.0.1"),_port);
   7:             OutputStream out=s.getOutputStream();
   8:         ...
   9:             out.flush();
  10:             s.shutdownOutput();
  11:             s.close();

View Full Code Here
   1: 
   2: import java.net.Socket;
   3: import java.net.InetAddress;
   4:         ...
   5:         try{
   6:             Socket s = new Socket(InetAddress.getLocalHost(), _port);
   7:             OutputStream out = s.getOutputStream();
   8:         ...
   9:             out.flush();
  10:             s.shutdownOutput();
  11:             s.close();

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:         
   6:         Socket sock = new Socket(host,port);
   7:         InputStream is = sock.getInputStream();
   8:         
   9:         OutputStream os = sock.getOutputStream();

View Full Code Here
   1:    protected ServerSocket server_socket;
   2:    protected Socket client_socket;
   3:    protected boolean blocking;
   4:         ...
   5:       throws IOException, SecurityException {
   6:       final Socket accepted_socket = JDK.accept(server_socket, true);
   7:       if( accepted_socket == null )
   8:         ...
   9:      try {
  10:         client_socket.shutdownOutput();
  11:         client_socket.shutdownInput();
  12:         ...
  13:    public void write( final output_port  p ) {
  14:       p.write( "#<socket:" + server_socket.getInetAddress() 

View Full Code Here
   1: import java.io.IOException;
   2: import java.net.Socket;
   3: 
   4:         ...
   5:     protected void finishConnection(){
   6:         Socket socket = processorTask.getSocket();
   7:         
   8:         ...
   9:                 if (!socket.isOutputShutdown()){
  10:                     socket.shutdownOutput();
  11:                 }

View Full Code Here

toString

public String toString()
Converts this socket to a String.
Overrides:
toString in interface Object
Returns:
a string representation of this socket.
Usages and Demos :

View More Examples of toString()
   1: 
   2: import java.net.Socket;
   3: import java.net.SocketException;
   4:         ...
   5: 
   6: public class SSHVersionSpySocket extends Socket {
   7:     PushbackInputStream pbIn;
   8:         ...
   9:     Socket              origSocket;
  10: 
  11:         ...
  12:     public String toString() {
  13:     return origSocket.toString();

View Full Code Here
   1: import java.net.ServerSocket;
   2: import java.net.Socket;
   3: 
   4:         ...
   5: class TransportImpl implements Transport {
   6:     Socket m_socket = null;
   7: 
   8:         ...
   9:                     "TransportImpl(int port, int timeout, int backlog) ERROR: "
  10:                             + e.toString());
  11:         }
  12:         ...
  13:             m_port = port;
  14:             m_socket = new Socket(host, port);

View Full Code Here
   1: import java.io.DataOutputStream;
   2: import java.net.Socket;
   3: import java.net.InetSocketAddress;
   4:         ...
   5:     
   6:     Socket                  socket = null;
   7:     ProtocolConfiguration   configuration = null;
   8:         ...
   9:     public String toString() {
  10:         return socket.toString();
  11:     }

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.net.Socket;
   3: import java.net.SocketAddress;
   4:         ...
   5: 
   6: abstract public class SocketDelegateImplBase extends Socket
   7: {
   8:         ...
   9:     private Socket socket;
  10: 
  11:         ...
  12:     public String toString() {
  13:     return socket.toString();

View Full Code Here
   1:         
   2:         Socket sock = null;
   3:         
   4:         ...
   5:             {
   6:                 System.out.println("LISTENER : from "+sock.toString()+" got a : "+e.getMessage());
   7:                 
   8:         ...
   9:                 {
  10:                     System.out.println("LISTENER : from "+sock.toString()+" didn't read expected bytes for payload ");
  11:                     break;
  12:         ...
  13:             {
  14:                 System.out.println("LISTENER : from "+sock.toString()+" got a : "+e.getMessage());

View Full Code Here