0

I am currently using

Socket s = new Socket(HOST, 8000);

to create a socket to connect to my ServerSocket server = new ServerSocket(8000).

With this, I can actually use server.accept(); to access the hostName for example.

However, how would I go off if I wanted to send custom parameters like a client name my client chooses before connecting to the server?

2
  • 4
    Once you've made the socket connection, you can develop any protocol you need for establishing client identity, et. al. Commented May 18, 2015 at 16:58
  • Your question is unclear. Please, clarify it. Commented May 19, 2015 at 20:10

1 Answer 1

2

The host name is established through the domain name service (DNS). If you want your client to have a host name, your client will need a DNS listing. If that's what you want to pursue, you might want to look at other questions on DNS either on this site or on the ServerFault or SuperUser site.

If you just want a client identifier for the convenience of your system, you can send it over the connection after the connection is established, using a protocol - that is, a communications format - that you establish for both client and server. For example, your client could send a serialized java.lang.String containing its name to the server as the first thing it does on the connection. Your server could then read the name from connection after it is established.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.