Package java.net

Examples of java.net.SocketAddress


    in = new DataInputStream(inStream);
    out = new DataOutputStream(outStream);
  }

  public void reconnect() throws IOException {
    SocketAddress address = socket.getRemoteSocketAddress();
    socket.close();
    socket.connect(address, timeout);
  }
View Full Code Here


        }
        if (con == null) {
            // Not in cache, so create new one and cache it
            try {
                closeSocket(); // Bug 44910 - close previous socket (if any)
                SocketAddress sockaddr = new InetSocketAddress(getServer(), getPort());
                con = new Socket();
                con.connect(sockaddr, getConnectTimeout());
                log.debug("Created new connection " + con); //$NON-NLS-1$
                cp.put(TCPKEY, con);
            } catch (UnknownHostException e) {
View Full Code Here

    }

    public void connect(int connectTimeout, int soTimeout)
           throws UnknownHostException, IOException {
        final String encoding = "ISO-8859-1";
        SocketAddress addr = new InetSocketAddress("localhost", port);
        socket = new Socket();
        socket.setSoTimeout(soTimeout);
        socket.connect(addr,connectTimeout);
        OutputStream os = socket.getOutputStream();
        writer = new OutputStreamWriter(os, encoding);
View Full Code Here

        private Socket socket;
        private Writer writer;
        private CustomReader reader;

        public WebSocketClient(int port) {
            SocketAddress addr = new InetSocketAddress("localhost", port);
            socket = new Socket();
            try {
                socket.setSoTimeout(10000);
                socket.connect(addr, 10000);
                os = socket.getOutputStream();
View Full Code Here

            while (!bufferQueue.isEmpty()) {
                Object encodedMessage = bufferQueue.poll();
               
                // Flush only when the buffer has remaining.
                if (!(encodedMessage instanceof IoBuffer) || ((IoBuffer) encodedMessage).hasRemaining()) {
                    SocketAddress destination = writeRequest.getDestination();
                    WriteRequest encodedWriteRequest = new EncodedWriteRequest(encodedMessage, null, destination);

                    nextFilter.filterWrite(session, encodedWriteRequest);
                }
            }
View Full Code Here

    private void readHandle(H handle) throws Exception {
        IoBuffer readBuf = IoBuffer.allocate(
                getSessionConfig().getReadBufferSize());

        SocketAddress remoteAddress = receive(handle, readBuf);
       
        if (remoteAddress != null) {
            IoSession session = newSessionWithoutLock(
                    remoteAddress, localAddress(handle));
View Full Code Here

                    buf.reset();
                    session.getFilterChain().fireMessageSent(req);
                    continue;
                }

                SocketAddress destination = req.getDestination();
               
                if (destination == null) {
                    destination = session.getRemoteAddress();
                }
View Full Code Here

     */
    @Override
    public String toString() {
        if (isConnected()||isClosing()) {
            try {
                SocketAddress remote = getRemoteAddress();
                SocketAddress local = getLocalAddress();
               
                if (getService() instanceof IoAcceptor) {
                    return "(" + getIdAsString() + ": " + getServiceName() + ", server, " +
                            remote + " => " + local + ')';
                }
View Full Code Here

                                    if (length > remaining) {
                                        length -= remaining;
                                        buffer.skipBytes(remaining);
                                    } else {
                                        buffer.skipBytes(length);
                                        SocketAddress remoteAddress = e.getRemoteAddress();
                                        ctx.getChannel().write(ACK.slice(), remoteAddress);
                                        state = State.WAIT_FOR_FIRST_BYTE_LENGTH;
                                        length = 0;
                                    }
                                }
View Full Code Here

                    session.write(message);
                }
            }
        });
        try {
            final SocketAddress address = new InetSocketAddress(9999);
            acceptor.bind(address);
            LOG.debug("Running the server for 25 sec");
            Thread.sleep(25000);
            LOG.debug("Unbinding the TCP port");
            acceptor.unbind();
View Full Code Here

TOP

Related Classes of java.net.SocketAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.