This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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 Murach's Java Servlets and JSP this week in the Servlets 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]
Don't get me started about those stupid light bulbs.
subject: sending my name
Similar Threads
Knock-Knock Client
creating new sockets
I am getting
client / server (communication problem...)
connection problem...