This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8839
    
    7

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]
 
 
subject: how to accept a binarydata in net abd change it to string
 
Similar Threads
simple socket programming
Address already used problem in Java Socket application
reading from TCP socket problem
JAVA SOCKET PROGRAMMING
Issue with simple multi-threaded Echo server and client program