package com.day1;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
public class Client {
/**刘诗华
* @param args
* @throws Exception
* @throws UnknownHostException
*/
public static void main(String[] args) throws UnknownHostException, Exception {
//网络IP地址对象
InetAddress ip=InetAddress.getByName("192.168.1.2");
//服务器端口号
int port=8080;
//与socket服务器建立连接
Socket socket=new Socket(ip,port);
//获取输出流对象
OutputStream out = socket.getOutputStream();
//向服务器发送数据内容,以字节数组形式发出
out.write("Hello word".getBytes());
//关闭socket对象,与服务器断开连接
out.close();
socket.close();
}
}