Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.DataOutputStream;
- import java.net.Socket;
- public class Ctlk {
- public static void main(String args[]) {
- try {
- Socket socket = new Socket("localhost", 2234);
- DataOutputStream outstream = new DataOutputStream(
- socket.getOutputStream());
- String msg = "mensagem.";
- outstream.writeUTF(msg);
- socket.close();
- } catch (Exception e) {
- }
- }
- }
- /*======================================*/
- import java.io.DataInputStream;
- import java.io.IOException;
- import java.net.ServerSocket;
- import java.net.Socket;
- public class Stlk {
- public static void main(String args[]) {
- try {
- ServerSocket server = new ServerSocket(2234);
- while (true) {
- Socket socket = server.accept();
- DataInputStream instream = new DataInputStream(
- socket.getInputStream());
- String msg = instream.readUTF();
- System.out.println(msg);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement