Package net.vo

Examples of net.vo.DataPacket


        @Override
        public void run() {
            try {
                geter = new ObjectInputStream(socket.getInputStream());
                DataPacket dp = (DataPacket) geter.readObject();

                if (dp.getTag() == SystemConf.fileConf) {
                    BufferedInputStream bis = new BufferedInputStream(
                            new FileInputStream(new File(
                                    dp.getContent())));

                    // 文件大小
                    long total = bis.available();
                    DataOutputStream o = new DataOutputStream(
                            socket.getOutputStream());
View Full Code Here


                    try {
                        InetAddress addr = InetAddress.getLocalHost();
                        String hostName = addr.getHostName();// 获取主机名
                        String ip = SystemConf.hostIP;// 获取ip地址
                        String message = output.getText();
                        NetDomain.sendUdpData(udpSocket, new DataPacket(ip,
                                hostName, message, SystemConf.text),
                                dp.getIp(), SystemConf.textPort);
                        fr.dispose();
                    } catch (UnknownHostException e1) {
                        e1.printStackTrace();
View Full Code Here

            // 发送TCP消息建立文件传输连接
            socket = new Socket(dp.getIp(), SystemConf.filePort);
            ObjectOutputStream toServer = new ObjectOutputStream(
                    socket.getOutputStream());
            toServer.writeObject(new DataPacket(ip, hostName, dp.getContent(),
                    SystemConf.fileConf));

            // 设置文件大小
            DataInputStream in = new DataInputStream(socket.getInputStream());
            long total = in.readLong();
View Full Code Here

        n.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    NetDomain.sendUdpData(new DatagramSocket(), new DataPacket(
                            SystemConf.hostIP, null, null, SystemConf.refuse),
                            dp.getIp(), SystemConf.textPort);
                } catch (SocketException e1) {
                    e1.printStackTrace();
                }
View Full Code Here

    }

    // 发送UDP数据
    private void sendUdpData(String hostName, String ip, String targetIp,
                             String message, int tag, int port) {
        DataPacket dp = new DataPacket(ip, hostName, message, tag);
        DatagramSocket socket = null;
        try {
            socket = new DatagramSocket();
            NetDomain.sendUdpData(socket, dp, targetIp, port);
        } catch (SocketException e) {
View Full Code Here

TOP

Related Classes of net.vo.DataPacket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.