简体   繁体   中英

Java tcp/ip sockets

Quick question regarding this

Socket(String host, int port)

If I use these arguments in a client, how would a specify the server have a name and thus reference it in the client?

EDIT

Please excuse me if it's vague. I'm writing and instant messenger in java and using this constructor for the client side socket, it wants to receive the host's name as a string and the host's port as a int. What I'm asking is how do I set/find the host's name in this case?

For example, is the String simply "127.0.0.1" if I'm running it locally? Or is it a specified name like "JavaServer" that I set somewhere somehow?

Well, you could read the documentation for that constructor :-)

It's either a host name (eg "chatserver.domain.com") or and IP address as a String (eg "192.168.1.10")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM