赞
踩
import java.io.IOException;
import java.net.*;
public class UDPClient {
public static void main(String[] args) throws IOException {
DatagramSocket clientSocket = new DatagramSocket();
InetAddress serverIP = InetAddress.getByName("localhost");
byte[] sendData = "Hello, UDP Server".getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, serverIP, 9876);
clientSocket.send(sendPacket);
byte[] receiveData = new byte[1024];
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
clientSocket.receive(recei
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。