You are on page 1of 3

97 學年 下學期 金門技術學院 資訊工程系 日四技三年級 網路程式設計 期中考 出題者 : 陳鍾誠

學號 : 姓名 : 分數 :
一、簡答題 (請列出中英文並詳細說明其意義)
1. 請說明 Internet 與 World Wide Web,並 2. 請說明何謂 GPS?何謂 GPRS?並比較兩者的不同點
比較兩者的不同點 (10%)。 (10%)。

3. 請說明何謂 TCP?何謂 UDP?並說明其 4. 請說明何謂 Socket Programming,並以 C# 的 Socket


在網路程式設計上的不同點 (10%)。 函式庫舉例說明? (10%)。

5. 請說明 HTTP 協定的格式,並說明其運 6. 請說明 Web Crawler 的原理,並說明其與


作方式? (10%)。 HTML、URL 之間的關係? (10%)。
學號 : 姓名 : 分數 :
二、請為下列程式加上註解 (40%)
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
public class TcpServer {
public static void Main() {
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 20);
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
newsock.Bind(ipep);
newsock.Listen(10);
while(true) {
Socket client = newsock.Accept();
IPEndPoint clientep = (IPEndPoint) client.RemoteEndPoint;
Console.WriteLine("Client End Point = " + clientep);
TcpListener listener = new TcpListener(client);
Thread thread = new Thread(new ThreadStart(listener.run));
thread.Start();
}
// newsock.Close();
}
}
public class TcpListener {
Socket socket;
public TcpListener(Socket s) {
socket = s;
}
public void run() {
while (true) {
byte[] data = new byte[1024];
int recv = socket.Receive(data);
if (recv == 0) break;
Console.WriteLine(Encoding.UTF8.GetString(data, 0, recv));
}
socket.Close();
}
}

You might also like