java网络编程框架

The java.net package of the J2SE APIs contains a collection of classes and interfaces that provide low-level communication details, allowing you to write programs that focus on solving the problem at hand.

The java.net package provides support for the two common network protocols

TCP

TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications.
TCP is typically used over the Internet Protocol, which is referred to as TCP/IP.

UDP

UDP stands for User Datagram Protocol, a connection-less protocol that allows for packets of data to be transmitted between applications.

 


 

Socket Programming

Sockets provide the communication mechanism between two computers using TCP.
The java.net.Socket class represents a socket, and the java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them.
After the connections are established, communication can occur using I/O streams.
Each socket has both an OutputStream and an InputStream.
The client's OutputStream is connected to the server's InputStream, and the client's InputStream is connected to the server's OutputStream.
TCP is a two-way communication protocol, hence data can be sent across both streams at the same time.

 

InetAddress

This class represents an Internet Protocol (IP) address.

 

posted @ 2015-08-11 22:03  时空穿越者  阅读(1653)  评论(1编辑  收藏  举报