Sockets :: Transfering data between remote PC
Ola,


I went blind in to this and got it to work on LAN but stuck on Global scale. Anyhow the software works in the following two cases:

1) I run both scripts on 1 PC and set address in client to localhost or 127.0.0.1
2) I run server on 1 PC and client on another PC where both PC's are connected to same LAN

However when i send the file to my friend and he runs the client where address is my IP
i get no response on server. We did a wireshark trace and seems both my and his port/socket are free and data is going past them. Both of us have that port free.

Server:

    public class Server
    {		
    	private void Listen() throws Exception
    	{
    		ServerSocket socket = new ServerSocket(1111);
    		Socket listener = socket.accept();
    		
    		BufferedReader reader = new BufferedReader(new InputStreamReader(listener.getInputStream()));
    		String out = reader.readLine();
    		System.out.println(out);
    	}	
    	
    	public static void main(String[] args)
    	{
    		try {
    			new Server().Listen();
    		} catch(Exception e) {}
    	}
    }



Client:

    public class Client
    {
    	private void Connect() throws Exception
    	{
    		Socket socket = new Socket("93.103.56.251", 1111);
    		PrintStream outgoing = new PrintStream(socket.getOutputStream());
    		outgoing.println("Hello Server");
    	}
    	
    	public static void main(String[] args)
    	{
    		try {
    			new Client().Connect();
    		} catch (Exception e){}
    	}
    }


Sockets :: Transfering data between remote PC
===

Ola,


I went blind in to this and got it to work on LAN but stuck on Global scale. Anyhow the software works in the following two cases:

1) I run both scripts on 1 PC and set address in client to localhost or 127.0.0.1
2) I run server on 1 PC and client on another PC where both PC's are connected to same LAN

However when i send the file to my friend and he runs the client where address is my IP
i get no response on server. We did a wireshark trace and seems both my and his port/socket are free and data is going past them. Both of us have that port free.

Server:

    public class Server
    {		
    	private void Listen() throws Exception
    	{
    		ServerSocket socket = new ServerSocket(1111);
    		Socket listener = socket.accept();
    		
    		BufferedReader reader = new BufferedReader(new InputStreamReader(listener.getInputStream()));
    		String out = reader.readLine();
    		System.out.println(out);
    	}	
    	
    	public static void main(String[] args)
    	{
    		try {
    			new Server().Listen();
    		} catch(Exception e) {}
    	}
    }



Client:

    public class Client
    {
    	private void Connect() throws Exception
    	{
    		Socket socket = new Socket("93.103.56.251", 1111);
    		PrintStream outgoing = new PrintStream(socket.getOutputStream());
    		outgoing.println("Hello Server");
    	}
    	
    	public static void main(String[] args)
    	{
    		try {
    			new Client().Connect();
    		} catch (Exception e){}
    	}
    }

