This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes sending my name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

sending my name

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
public class KnockKnockClient
public static void main(String[] args) throws IOException
Socket kkSocket = null;
PrintWriter out = null;
kkSocket = new Socket("taranis", 4444);
out = new PrintWriter(kkSocket.getOutputStream(), true);
catch (UnknownHostException e)
System.err.println("Don't know about host: taranis.");
catch (IOException e)
System.err.println("Couldn't get I/O for the connection to:
String fromUser = new String("Lucky Singh");;
while ((fromUser = in.readLine()) != null)
if (fromUser != null)
Is the aboev code correct for sending my name to a server?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Please don't cross-post. Finish the conversation you started here.

[Jess in Action][AskingGoodQuestions]
It is sorta covered in the JavaRanch Style Guide.
subject: sending my name