All pastes #409406 Raw Edit

Anonymous

public text v1 · immutable
#409406 ·published 2007-03-25 17:55 UTC
rendered paste body
package Netzwerk;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;

public class Client {
	Socket MyClient;
	DataInputStream input;
	
	public Client(){
		
		try{
		MyClient = new Socket("192.168.123.101", 12345);
		}
		catch(Exception exception){
			System.out.println(exception);
		}
		senden();
		
	}
	
	public void senden(){
		ObjectOutputStream oos=null;
		try{
		
			oos=new ObjectOutputStream(MyClient.getOutputStream());
		}
		catch(IOException exception){
			
		}
	    String s="sadasd";
	    try{
	    	oos.writeObject(s);
	    }
	    catch (Exception exception){
	    	
	    }
		
	}
	
	public static void main(String[] args) {
		Client client=new Client();
		
	}

}


//////////////////////////////////////////////////////////////////////////////////////////////

package Netzwerk;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;


public class Server {
	
	ServerSocket MyServerice=null;
	Socket clientSocket = null;
	ObjectInputStream input;
	
	public Server(){
		
	
	    try {
	       MyServerice = new ServerSocket(12345);
	        }
	        catch (IOException e) {
	           System.out.println(e);
	        }
		
		
	    try {
	        clientSocket = MyServerice.accept();
	         }
	     catch (IOException e) {
	        System.out.println(e);
	     }
	    //System.out.println("connection accepted");
	   // System.out.println(clientSocket.toString());
	    empfangen();
    
    
	}
	
	public void empfangen() {
		while (input==null){
			try {
			       input = new ObjectInputStream(clientSocket.getInputStream());
			    }
			    catch (IOException e) {
			       System.out.println(e);
			    }
		}
		System.out.println("input"+input.toString());
			    
	
			//empfange
		
		// TODO Auto-generated method stub
		
	}

	public static void main(String[] args) {
		Server serv=new Server();
		
		// TODO Auto-generated method stub

	}

}