Created
September 21, 2013 17:56
-
-
Save jpt1122/6652702 to your computer and use it in GitHub Desktop.
This file contains 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.*; | |
public class SocketServer | |
{ | |
public static void main(String args[]) throws IOException | |
{ | |
ServerSocket s = new ServerSocket(4444); | |
try | |
{ | |
while(true) | |
{ | |
Socket s1=s.accept(); | |
InputStream s1In = s1.getInputStream(); | |
DataInputStream dis = new DataInputStream(s1In); | |
String st = new String (dis.readUTF()); | |
System.out.println(st); | |
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(s); | |
dos.close(); | |
s1out.close(); | |
s1.close(); | |
} | |
} | |
catch(Exception e) | |
{ | |
System.out.println(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment