How to make socket connection for remote IP ? (I know how to do it for Local IP)
<p>How to make socket connection for remote IP ? I know fro Loacl Ip ? </p>

<p>Thanks in advance
Ranganath.t.m</p>

<p>Mycode for local IP  is:</p>

<pre><code>package com.asmaitha.client;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.logging.Handler;

import javax.print.attribute.standard.Finishings;
import javax.swing.SwingWorker;

public class Client {

    static Socket s,socket;
    DataInputStream dataInputStream;
    DataOutputStream datOutputStream;
    static TextArea tarea;
    String dataFromServer;
    /**
     * @param args
     */
   class MyClient1 extends SwingWorker&lt;String,String&gt;
   {

        @Override
        protected String doInBackground() throws Exception {
            // TODO Auto-generated method stub
            try 
            {
//              InetAddress serverAddress = InetAddress.getByAddress("110.234.149.86",null);//getByName("110.234.149.86") ;
//              tarea.setText(serverAddress.getCanonicalHostName());
                System.out.println("calling socket");
                socket = new Socket("192.168.1.31",8080);
                if(socket != null)
                {
                    System.out.println("ContentApp"+ "Socket Successfully created");
                }
            } 
            catch (IOException e) {
                System.out.println("ContentApp"+ "Socket IOException");
                e.printStackTrace();
            }
            try 
            {
                dataInputStream = new DataInputStream(socket.getInputStream());
                System.out.println("ContentApp"+ "DataInputstream Successfully created");
            }
            catch (IOException e) {
                System.out.println("ContentApp"+ "Datainputstream failed");
                e.printStackTrace();
//              return false;
            }
            try
            {
                datOutputStream = new DataOutputStream(socket.getOutputStream());
                datOutputStream.writeUTF("Hi This is client!");
                System.out.println("ContentApp"+ "Dataoutputstream Successfully created");
            } 
            catch (IOException e) 
            {
                System.out.println("ContentApp"+ "Dataoutputstream failed");
                e.printStackTrace();
//              return false;
            }

            if(socket != null)
            {
               while(socket!=null)
               {
                dataFromServer = dataInputStream.readUTF();
                done();
               }
            }
            return dataFromServer; 
            }
        @Override
        protected void done() {
        if (dataFromServer != null)
        {
            tarea.setText("");
        tarea.append(dataFromServer);
        }
        else
        tarea.append("no value from server !");
        }

        }


    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("calling theframe");
        Frame frame=new Frame("Button Frame");
        tarea = new TextArea("",5,40);
        frame.add(tarea);
        frame.setLayout(new FlowLayout());
        frame.setSize(300,200);
        frame.setVisible(true);
        frame.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
        System.out.println("calling the Client");
        Client c = new Client();
        MyClient1 myClient = c.new MyClient1() ;

        myClient.execute();

        /*Client1 client = new Client1();
        if(client == null)
        {
            System.out.println("client isnull");
            return;
        }
        Thread clientThread = new Thread(client);
        if(clientThread!=null)
        {
            System.out.println("strating clent1");
            clientThread.start();
        }*/



        /*try {
            s = new Socket("110.234.149.86",8080);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }*/

    }

}
</code></pre>
