Dear Friends i am working on my Project of Chatting...

i want to chat with the Client having the specific ip address, so i just pass the ip address of my friend to the server and server will send my message to that ip address... on which a client i listening...

so please tell me

What did the Object of Socket class contain?

can i give the specific ip to connect to the socket, which is registered or connected with the server???

you can use something like this

int port = 8000;
String ipAdd = "";
int timeout = 1000;

SocketAddress sockAddr = new InetSocketAddress(ipAdd, port);
Socket s = new Socket();
s.connect(sockAddr, timeout);

Dear dickersonka,

THANX for the Reply... :)

BUT Dear Friend,

I want to compare the given ip with the ip bind with the perticular socket..


if (clientsocket.equals("");

but it doesn't work, :scared:
plz tell me how can i get the clientsocket ip address so i can compare it with the string of ip address.

I'll help out, but you just need to tell us what you want, if you want to compare ips then say that, not about how to create a socket

you are trying to compare objects with clientsocket.equals

you can use

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.