Regarding an exception

17 views
Skip to first unread message

Bhuvaneshwari Kaliappan

unread,
Feb 9, 2009, 11:35:07 PM2/9/09
to jnmp2p
class EstablishConnection{

import org.net.Msg.*;
import org.net.p2p.*;
public static void Main(String[] args){
EstablishConnection e=new EstablishConnection();
Protocol prot=new Protocol(e);
prot.addHandler("hello","say_hello");
jnmp2p jnm=new jnmp2p(prot,12000); //random port number
//reading the ip address to connect to
BufferedReader in=new BufferedReader(new InputStreamReader
(System.in));
String ip=in.readLine();
Connection conn=jnm.connect(ip); //ip address to connect
to
String msgHeader="hello"; //the header corresponding to
the handler function
String msgBody="Subodh"; //msg content
Msg m=conn.createMsg(msgHeader,msgBody);
conn.sendMsg(m);

}

public void say_hello(Connection conn,Msg msg){
System.out.println("hello "+msg.getContent());
}
}


When i executed the above code,am getting "cannot find other computer"
in my output screen and NullPointerException in the line conn.sendMsg
(m);...please suggest me a way to resolve this exception....Thanks in
advance

gandalf

unread,
Feb 10, 2009, 8:34:56 AM2/10/09
to jnmp2p
The problem probably is that both the computers that you have
connected are not in the same subnet.
If youve directly connected both the computers without a router, then
this is definitely the problem. To resolve the problem set the IP
address of both computers to 192.168.x.y and 192.168.x.z where x y and
z are in between 1-255 and then set subnet mask of both computers to
255.255.255.0.
Without these settings, no application can connect between both
computers, not just jnmp2p.

Tell me if this resolves the problem.


On Feb 10, 9:35 am, Bhuvaneshwari Kaliappan

gandalf

unread,
Feb 10, 2009, 8:35:36 AM2/10/09
to jnmp2p
The null pointer exception is occurring as a result of the computers
not being able to connect

On Feb 10, 9:35 am, Bhuvaneshwari Kaliappan
<bhuvaneshwari.kaliap...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages