wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes how to accept a binarydata in net abd change it to string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to accept a binarydata in net abd change it to string" Watch "how to accept a binarydata in net abd change it to string" New topic
Author

how to accept a binarydata in net abd change it to string

jim chou
Greenhorn

Joined: Feb 15, 2004
Posts: 4
below is my code
//client
import java.net.*;
import java.io.*;
public class Client{
public static void main(String args[])throws IOException{
Socket s=new Socket("127.0.0.1",1234);
OutputStream os=s.getOutputStream();
PrintStream out=new PrintStream(os);
out.println("hello");
}
}
import java.net.*;
import java.io.*;
public class server{
public static void main(String args[])throws IOException{
ServerSocket s=new ServerSocket(1234);
Socket ss=s.accept();
InputStream is=ss.getInputStream();
OutputStream os=ss.getOutputStream();
/*what can i do to accept the data from client"hello" and show it in the server.
*/
}
}
thank you very much.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

Read through the Custom Networking trail of the Java Tutorial. It's full of helpful examples, including reading to and writing from sockets.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
GeeCON Prague 2014
 
subject: how to accept a binarydata in net abd change it to string