Submitting and recieving classes through java
Hi,
I tried to write a program, which submitts and recieves java classes. This programm should work on a direct connection, where one client connects to another to submit the class with its contend.
Unfortunaly I recieve the following error:
java.netSocketException:Connection reset
Here is my code:
publicclass Submit
{
private InetAddress addr;
privateint port;
public Submit(String ip,int b)throws IOException, UnknownHostException
{
addr=InetAddress.getByName(ip);
port=b;
}
public Submit(InetAddress a,int b)throws IOException
{
addr=a;
port=b;
}
public InetAddress getInetAdress()
{
return addr;
}
publicvoid write(Object tosend)throws IOException
{
Socket so =new Socket(addr, port);
ObjectOutputStream out =new ObjectOutputStream(so.getOutputStream());
out.writeObject(tosend);
out.close();
so.close();
}
}
publicclass Recieve
{
private InetAddress addr;
privateint port;
public Recieve(String ip,int b)throws IOException, UnknownHostException
{
addr=InetAddress.getByName(ip);
port=b;
}
public Recieve(InetAddress a,int b)throws IOException
{
addr=a;
port=b;
}
public InetAddress getInetAdress()
{
return addr;
}
public Object get()throws IOException, ClassNotFoundException
{
Socket so=new Socket(addr, port);
ObjectInputStream in =new ObjectInputStream(so.getInputStream());
Object temp=in.readObject();
in.close();
so.close();
return temp;
}
}
Just assume that every necassary import is done. The two codes compile perfactly, but as soon as I try it with my computers with the following ip:
192.168.0.101
192.168.0.102
It throws the error:
java.netSocketException:Connection reset
This only happens on the Pc, who is actually recieving.
I also tried it with one computer via localhost/127.0.0.1/192.168.0.1 and i got:
java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
In case you need the program, which starts the two classes just let me know, but it is not much of code, just putting the two classes in an while loop and leeting them repeat the connection.
I hope you can help me.

