One of the clients creates a ServerSocket and calls accept(), the other client connects to it.
You could also use UDP instead of TCP. But that's usually more advanced, as you have to deal with limited message size, duplicated messages, lost messages, out-of-order messages, firewall issues, and whatnot.
> but as client is running on that port ( port ,ip etc)
What do you mean by 'running'?
> so u cant create server socket on same
> port to listen for connection frm other clients
That's what I would normally mean by 'running on that port'.
Do you have some other meaning in mind?
sir,i want to tell that is it possible tthat one program act both as a client and server,I think it is not possible.
What my basic need is to connect to client to whom i want to send message, without passing that message through server ie i want ppp connection between two clients.
please tell me is it possible, if yes then guide me how to do it.
As i am begginer of java i don't know much about advance java or rmi.
I will be very thankfull to you for your valuable time and Replies