0

Hi,

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???

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dickersonka
0

you can use something like this

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

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

Dear dickersonka,

THANX for the Reply... :)

BUT Dear Friend,

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

e.g

if (clientsocket.equals("192.168.1.5");

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.

0

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

clientsocket.getInetAddress().getHostAddress().equals("192.168.1.5")
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.