Created
September 21, 2013 17:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.*; | |
import java.io.*; | |
import java.util.*; | |
public class SocketClient | |
{ | |
public static void main(String args[]) throws IOException | |
{ | |
Socket s1 = new Socket("localhost",4444); | |
while(true) | |
{ | |
OutputStream s1out = s1.getOutputStream(); | |
DataOutputStream dos = new DataOutputStream (s1out); | |
System.out.print("Enter String Which You Want To Send:- "); | |
Scanner s=new Scanner(System.in); | |
String str=s.next(); | |
dos.writeUTF(str); | |
InputStream s1In = s1.getInputStream(); | |
DataInputStream dis = new DataInputStream(s1In); | |
String st = new String (dis.readUTF()); | |
System.out.println(st); | |
dis.close(); | |
s1In.close(); | |
s1.close(); | |
}//end while | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment