import java.net *;. import java.io. *; public class SimpleServer {public static void main (String args []) {ServerSocket s = null; Socket s1; String sendString = "Hello Net World!"; OutputStream s1out; DataOutputStream Dos; // register your service on port 5432 try {s = new serversocket (5432);} // run the listen / accept loop forever while (true) {TRY {// Wait Here and listen for a connection s1 = s.accept (); // Get a communication stream for soocket s1out = s1.getOutputStream (); dos = new DataOutputStream (s1out); // Send your string (UTF provides machine-independent format)!Dos.writeutf (SendString); // Close The Connection, But Not The Server Socket S1out.close (); S1.Close ();}}}}};
/ ** *
Title: p> *
Description: p> *
Copyright: Copyright (c) 2004 p> *
Company: p> * @ Author not attributable * @version 1.0 * /
Import java.net. *; import java.io. *;
Public Class SimpleClient {public static void main (string args []) throws ioException {int C; socket S1; inputStream S1in; DataInputStream DIS;
// Open Your connection to myserver, at port 5432 s1 = new socket ("127.0.0.1", 5432); // Get An Input File Handle from The Socket and Read The Input S1IN = S1.GETInputStream (); DIS = New DataInputStream (S1In);
String ST = new string (dishdutf ()); system.out.println (st);
// when Done, Just Close the connection and exit s1in.close (); S1.Close ();}}