Javaweb 网页编程 B/S架构
TCP/IP 网络编程 C/S架构web
如何实现网络通讯
一、通讯双方的地址:编程
IP 192.168.1.1 端口号 192.168.16,124::5900
二、网络通讯的协议网络
http,ftp,smtp,tcp,udp... tcp/ip
public class InetAddress
* IP用来惟必定位一台网络上的计算机架构
IP地址的分类tcp
使用32位(4字节)地址,十进制,每段有0-255,一共42亿地址。
例如127.0.0.1函数
这里显示的不完整,还除以了16
长度为128位,是IPv4地址长度的4倍,8个无符号整数构成,十六进制
2001:0DB8:0000:0023:0008:0800:200C:417Aspa
A类:1.0.0.0-126.0.0.0
B类:128.1.0.0-191.255.0.0
C类:192.0.1.0-223.255.255.0code
域名 方便记ip
操做:
InetAddress 没有构造函数对象
static InetAddres getByAddress(byte[] addr) 返回InetAddress对象
建立对象用静态方法:ip
InetAddress ia = InetAddress.getByAddress("127.0.0.1"); InetAddress ia = InetAddress.getByAddress("localhost"); InetAddress ia = InetAddress.getByAddress("www.baidu.com");
获取ip地址、域名
getCanonicalHostAddress(); getHostAddress(); getHostName();