Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.DatagramPacket;
- import java.net.DatagramSocket;
- import java.net.InetAddress;
- import java.net.Socket;
- import java.util.Scanner;
- import java.util.concurrent.*;
- public class Client {
- public static void main(String[] args) {
- try {
- DatagramSocket datagramSocket = new DatagramSocket();
- Scanner sc = new Scanner(System.in);
- InetAddress ip = InetAddress.getLocalHost();
- byte[] b = null;
- while(true) {
- String s = sc.nextLine();
- b = s.getBytes();
- DatagramPacket send_message = new DatagramPacket(b, b.length, ip, 1234);
- datagramSocket.send(send_message);
- if (s.equals("END")) {
- break;
- }
- }
- }
- catch (IOException i) {
- i.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement