File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

sending my name

Lucky Singh
Ranch Hand

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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending my name