如果創建了一個Socket對象
Socket s = new Socket (
InputStream is = s
// Read from the stream
is
s
接下面我們將示范一個流套接字的客戶程序
Listing
// SSClient
import java
import java
class SSClient
{public static void main (String [] args)
{String host =
// If user specifies a command
// represents the host name
if (args
host = args [
BufferedReader br = null;
PrintWriter pw = null;
Socket s = null;
try
{// Create a socket that attempts to connect to the server
// program on the host at port
s = new Socket (host
// Create an input stream reader that chains to the socket´s
// byte
// converts bytes read from the socket to characters
// conversion is based on the platform´s default character
// set
InputStreamReader isr;
[
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27216.html