Title: Internet Access in .NET
1(No Transcript)
2??????? ? ???????? ????????????
???????????? ?? .NET Framework
http//www.nakov.com/dotnet/
?????? ???????
????????? ???????????
3?????????? ??????
- ?????? ???????? ?? .NET Framework
- ?????? ???????? ?? ????? C
- ?????? ???????? ?? ?????????? ?????, TCP/IP,
????????? ? ?????? - ???????? ?? ???????????? ???????????? ?
?????????????
4??????????
- 7-???????? OSI ?????
- ??????? ??????? ???????
- IP ?????, DNS, ????, ?????? ?????????
- TCP, UDP, ????? ??????
- ??????? ??????? ??????
- ??????? ?? ??????? ????????????
- ??????????? ?? TCP
- TcpClient
- TcpListener
- ?????????? ?? ????? ??????? ????????????
5?????????? (2)
- ????????? Socket, IpAddress, Dns, IPEndPoint
- ??????????? ?? UDP UdpClient
- ?????? ?? ???????? ???????
- WebClient, HttpWebRequest, HttpWebResponse
- ????????? ?? ?????? ? e-mail
- ????????? ? ?????????? ?? e-mail
- ??????? ?? ????????? ?? e-mail
- ?????????? ??????? (attachments)
67-????? OSI ?????
- ????????? ??????????? ????????? ?? ??
???????????? - ???? ?? ?? ????????? ?
- ??????? ??????
- ??????????
- ??????
- ? ??.
Physical ( ????????? ???? )
77-????? OSI ?????
- ????????? ?????????? ????????? ?? ??????????
????? ??? ??????? ?????????????? ?????????? - ??????? ????????, ??????, ...
- ????????? ??????????? ????
- ???????? ?? ????????, ?????????? ??? ???????????
???? - ????????? Ethernet, PPP, ...
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
87-????? OSI ?????
- ????????? ????????? ?? ??????? ??????????
(??????) - ??????? ???????? ?????? ? ???????
- ????????? ????????????? (routing)
- ????????? IP, IPv6, IPX, X.25,
Network ( ??????? ???? )
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
97-????? OSI ?????
- ?????????? ?????????????? ??????
- ????????? ??????????? ? ?????????? ?? ??????? ??
????? ????? ??? ???????? - ????????? TCP, UDP, ...
Transport ( ??????????? ???? )
Network ( ??????? ???? )
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
107-????? OSI ?????
- ????????? ??? ?????????? ?? ????????, ????????? ?
???????? ?????? ??????? ?? (?????) - ????????? TLS, RPC, NetBIOS, ...
Session ( ??????? ???? )
Transport ( ??????????? ???? )
Network ( ??????? ???? )
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
117-????? OSI ?????
- ????????? ???, ????????? ?? ??????, ?????? ??
??????????? ?? ??????? - ????????? XML, SOAP, ASN.1, MIME, ...
Presentation ( ?????????????? ???? )
Session ( ??????? ???? )
Transport ( ??????????? ???? )
Network ( ??????? ???? )
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
127-????? OSI ?????
- ???????? ????????? ?? ?????????? ??????
- ????????? HTTP, SMTP, POP3, FTP, DNS, ...
Application ( ???????? ???? )
Presentation ( ?????????????? ???? )
Session ( ??????? ???? )
Transport ( ??????????? ???? )
Network ( ??????? ???? )
Data Link ( ????????? ???? )
Physical ( ????????? ???? )
13??????? ???????
- IP ?????
- ???????? 32-????? (64-?????) ????? ?? ????????
- ????? ???????? ? ???????? ? ??????? TCP/IP ?????
?? ??? IP ????? - ??????? ?? ???? 4 ?????????????? 8-?????? ?????
????????? ? ????? - ????? ???????? ????? ?? ???? ?? ??????? IP ??????
- ???????
- 192.168.0.1
- 212.50.1.217
14??????? ???????
- DNS (Domain Name Service)
- ??????, ????? ??????????? ????? ?? ???????? ? IP
?????? ? ????????? - ?????? ?? ????? www.google.com ???????????? IP
???????? - 216.239.59.104
- 216.239.59.99
- ?????? ?? IP ????? 194.12.244.90 ????????????
??????? - zadnik.org
- www.zemlemoria.org
15??????? ???????
- ????
- ???????? ????????????? ?? TCP ??? UDP ??????
(????? ?? ?????) ? ??????? ?? IP ????? - ????? ????? 0 ? 65535
- ????????? ?? 0 ?? 1024 ?? ???????? ?? ?????????
(????????) ?????????? - ??????
Internet Explorer IP 10.0.52.111 Source Port
1033
TCP
Web Server IP 216.239.59.99 Port 80 (HTTP)
TCP
TCP
Internet Explorer IP 10.0.52.111 Source Port
1034
TCP
16??????? ???????
- ?????? ?????????
- ???????? ? ???? ?????? ?? ? ???????? ??? ???????
????? - ????????? ????? ? ????????
- ??????? ?? ?????????? ?? ????????
- ??????????? ??? ????? ????? ??????????? ??????
????????? - Ethernet ?????? ???????
- ?????
- VPN ??????
- ISDN
17??????? ???????
- ?????? ?????????
- ????????? ????????? ??? IP ?????
- ???? ?????? ???? ?? ??? ??????? ???????
?????????? ? ??????? ???????? IP ?????? - Loopback ?????????
- ???????????? ???????? ????????? ?? ??????? ??????
??? ????????? ?????? - ??? ????? 127.0.0.1 ? ??? localhost
18?????????? TCP
- TCP ????????? ???????? ?????????? ??????????????
????? (?????) - ?????????, ?? ??????????? ????? ?? ?????????? ???
????????? ? ? ????? ??? - ??? ?? ? ???????? ?? ?? ???????? ???????, ??
???????? ?????? - ???????? ?? ? ??????????, ? ????? ????? ??
?????????? ?? ??????? ? ???????????? ?? ????? - ???????????????? ????? ?????????? ?????? ????? ??
??????????? ? ???? ?? ?? ????????
19?????????? UDP
- ????????? ????????? ? ???????? ?? ?????
?????????? ???? ?? ???? ?????? ? ?????, ????????
"datagram ??????" - UDP ?? ????????? ???? ?? ?????????? ?? datagram
????????, ???? ?? ?????? ?? ?????????? - ??-???? ?? TCP, ?????? ?? ??????? ??????????????
????? - ???????? ?? ? ??????, ? ????? ????????? ???
??-?????? ???????? ?? ???????????? - ??? ????? ????
- ??? ?????????? ?? ????????? (chat)
- ??? ????? ? ????? ??????????????????
20????? ??????
- ??? TCP ????????? ????? TCP ?????? (????? ??????,
socket connection) ?? ???????????? ? 4 ???????? - Source_IP IP ????? ?? ???????
- Source_Port ???? ?? ???????
- Dest_IP IP ????? ?? ???????
- Dest_Port IP ????? ?? ???????
- ??????
- (192.168.0.22733 ? 212.50.1.21780)
- ??? UDP ????????? ????? UDP ????? ?? ????????????
??? ?????? 4 ???????? (IPport)-???????? ?
(IPport)-?????????
21??????? ??????? ??????
- ???????? ?? ???????? ??????????, ?????
??????????? ?????????????? ?? ??????????????
???????? - ? ???????? ??????? ????? ?????????? ??????
- ???????????? ?????? ?? ???? ?????????? ????
?????? ???? ????????
HTTP 80 ?????? ?? Web-???????
SMTP 25 ????????? ?? e-mail
POP3 110 ????????? ?? e-mail
FTP 21 ?????? ?? ?????????? ???????
DNS 53 ????????? ?? IP ?? ??? ?? ??????
SSH 22 ??????? ?????? ?? ????????? ????????
22??? ??? ?????????? ?????? ?? ???????
?????????? ???????????? ?????? ?? ???? 80
?????????? ???????????? ??????
80
2096
?????? ??????
?????? ??????
23??????? ?? ??????? ????????????
- ????????? ?? ?????? ? TCP ? UDP ?? ?
?????????????? System.Net.Sockets - ?? ??????? ???????????? ?? ???????? ?
?????????????? System.Net - ?? ???????? ?? TCP ?????????????? ????? ??
????????? ????????? - TcpClient ??????? ?? ??? ??????? ???? ??
?????????? ?????? - TcpListner ?????? ???? ? ????? ?? ???? ??
?????? ?????? - ?? ????????????? ?? ??????????? ?? UDP ??
???????? ????? UdpClient
24?????? TcpClient
- ???????? ?? ?? ????????????? ?? ?????? ?? TCP
????????? - ????????????? TcpClient()
- ??????? ?????????????? ????? (?????)
- ????????? ????????? ? ???? ?? ??????? ??
????????????? ??????? - C?nnect()
- ??????? ?? ? ????????? ?????? ?? ????????? ????
(????????? ????????) - ??? ???????? ?? ???? ?? ?? ????????? ?? ????????
SocketException
TcpClient tcpClient new TcpClient() tcpClient.C
onnect("www.devbg.org", 80)
25?????? TcpClient
- ????????????? TcpClient(string host, int port)
- ?????? ?????? ?? ???????? TCP ??? ?????????
?????? ?? ????????? ???? - ????????? ????????? ? ???? ?? ??????? ??
????????????? ??????? - ??? ???????? ?? ???? ?? ?? ????????? ?? ????????
SocketException
TcpClient tcpClient new TcpClient("212.5.121
.5", 8080)
26TcpClient ????? ??????
// ????????? ?? ????????? TCP ??????? ?? 130 ??
150 for (int port 130 port lt 150 port)
TcpClient tcpClient new TcpClient() try
tcpClient.Connect("127.0.0.1",
port) Console.WriteLine("0 open",
port) catch (SocketException)
Console.WriteLine("0 closed", port)
finally tcpClient.Close()
27???????????? 1
28??????????? ???? TcpClient
- ?????????? NetworkStream ?? ?????? ? ??????
- ?????? (????????) ?? ????? ?????????? Read()
?????? ?? NetworkStream - ????????? ?? ????? ?????????? Write() ? Flush()
???????? ?? NetworkStream - ??? ?? ????????? Flush(), ??????? ???? ?? ?? ??
???????? ??????? (???????? ??????????)
TcpClient con new TcpClient("localhost",
80) NetworkStream ns con.GetStream()
byte data new byte4096 int bytesRead
ns.Read(data, 0, data.Length)
ns.Write(data, 0, data.Length) ns.Flush()
29?????? ? TcpClient ??????
TcpClient tcpClient new TcpClient() tcpClient.C
onnect("localhost", 80) NetworkStream ns
tcpClient.GetStream() using (ns)
StreamWriter writer new StreamWriter(ns)
writer.Write("GET http//localhost/
HTTP/1.0\n\n") writer.Flush() byte buf
new byte4096 while (true) int
bytesRead ns.Read(buf, 0, buf.Length) if
(bytesRead 0) break // Server closed
the connection string data
Encoding.ASCII.GetString( buf, 0,
bytesRead) Console.Write(data)
30???????????? 2
- ??????????? ?? TCP ????? ???? TcpClient ?
NetworkStream
31?????? TcpListener
- ???????? ?? ?? ????????? ?? ???????, ?????
????????? ????????? TCP ?????? - ????????? TcpListener(int port),
TcpListener(IPEndPoint) - ??????? ????????? ?????, ??????? ? ?????????
????????? ? ???? - ??????? Start()
- ??????? ?? ????? ?? ?????? ?? ????????? ??
???????? TCP
TcpListener server new TcpListener(2222)
server.Start()
32?????? TcpListener
- AcceptTcpClient()
- ?????? ????????? ?????? ?? ?????? ? ??????? ??
??? TcpClient ????? - ????????? ????????
- TcpClient ??????? ????????? ?????? ???????????
????? ??????? ? ??????? - ???????? ? ?????????? ?? ??????? ???????
???????????? - ?????? ????????? ?? ????????? ? TcpClient,
???????? (TcpListener) ???? ?? ????? ?? ????
??????
TcpClient client server.AcceptTcpClient()
33TcpListener ??????
- IPEndPoint serverEndPoint
- new IPEndPoint(IPAddress.Any, 2222)
- TcpListener server
- new TcpListener(serverEndPoint)
- server.Start()
- while (true)
-
- TcpClient client server.AcceptTcpClient()
- NetworkStream ns client.GetStream()
- using (ns)
-
- StreamWriter writer new StreamWriter(ns)
- writer.WriteLine("0dd.MM.yyyy HHmmss",
- DateTime.Now)
- writer.Flush()
-
34???????????? 3
35?????????? ?? ????? ???????
- ?? ?????????? ?? ????? ??????? ???????????? ??
????????? ?????
class ThreadedTcpServer public static void
Main() TcpListener server new
TcpListener(2222) server.Start()
while(true) TcpClient client
server.AcceptTcpClient() ClientThread
clientThread new ClientThread(client)
Thread thread new Thread( new
ThreadStart(clientThread.ServeClient))
thread.Start()
36?????????? ?? ????? ???????
class ClientThread private TcpClient
mTcpClient public ClientThread(TcpClient
aTcpClient) mTcpClient aTcpClient
public void ServeClient() using
(NetworkStream ns mTcpClient.GetStream())
StreamWriter writer new
StreamWriter(ns) writer.Write("Enter your
name") writer.Flush() StreamReader
reader new StreamReader(ns) string name
reader.ReadLine() writer.WriteLine("Hello
, " name) writer.Flush()
mTcpClient.Close()
37???????????? 4
- TCP ?????? ?? ?????????? ?? ????? ???????
???????????? TCP ??????
38?????? Socket
- System.Net.Sockets.Socket
- ????????? ????? ???????? ??????????? ?? ????????
????????? (TCP, UDP, IP, IPv6, ICMP, IGMP, IPX ?
??.) - ???????? ???????-??????????? ? ???????-???????????
??????????? - ????????? ?????????? "Berkeley sockets"
- ???????? ???????? ????? ?? ?? ??????????
????????? ??? ?????????? - ???? ????? ??-?????? ????????? ?????? TcpListener
? TcpClient
39?????? Socket
- ??-????? ?????? ?? ????? Socket
- Bind() ???????? ?????? ? ????? ????????? ? ????
- Listen() ????? ?? ?????? ??????
- Accept() ?????? ????????? ??????
- Connect() ?????? ?????? ??? ????? ???? ?? ?????
???? - Send(), Receive() ??????? / ?????? ????? ???
???????-??????????? ?????? - ReceiveFrom(), SendTo() ??????? / ?????? ??????
??? ???????-??????????? ?????? - BeginConnect(), EndConnect(), BeginSend(),
EndSend(), ?????????? ???????
40?????? IpAddress
- ?????? IpAddress ???????????? ???? IP ?????
(???????? 192.168.0.1) - ???????????
- Parse(string) ???????? IP ????? ?? ???
- IPAddress.Loopback ????? IP ?????? ?? loopback
?????????? (127.0.0.1) - IPAddress.Any ???????? ?? ?? ?????????? ??
????? ????? (0.0.0.0)
public IPAddress(long address)
IPAddress ip IPAddress.Parse("10.0.1.1")
41?????? Dns
- System.Net.Dns ?????????? ?????? ?? DNS
???????? - Resolve() ?????????? IP ????? ?? ??? ?? ???? ?
?????????
IPHostEntry iphe Dns.Resolve("www.devbg.org") C
onsole.Write("Host 0 --gt ", iphe.HostName) for
each (IPAddress ip in iphe.AddressList)
Console.WriteLine("IP 0", ip) // Host
www.devbg.org --gt IP 195.69.120.35 IPHostEntry
loopback Dns.Resolve("127.0.0.1") Console.Write
Line("IP 0 --gt 1", loopback.AddressList0,
loopback.HostName) // IP 127.0.0.1 --gt
localhost
42?????? IPEndPoint
- ?????? ???????? IpAdressport
- ????????????
- IPEndPoint(IPAddress address, int port)
- ??????
IPAddress smtpIP IPAddress.Parse("192.168.1.
1") IPEndPoint smtpServerEndPoint new
IPEndPoint(smtpIP, 25) TcpClient tcpClient new
TcpClient() tcpClient.Connect(smtpServerEndPoint)
43?????? UdpClient
- UDP ????????????? ? ???????-???????????
- ?? ?? ?????? ?????????????? ?????
- ?? ? ????? ?? ????? Listener ? Client ??????
???? ?? ???????? ?? UdpClient ????? - ????????????
- UdpClient(int port) ??????? UdpClient ????? ?
?? ??????? ? ???????? ???? ?? ????????? ?????? - UdpClient() ??????? UdpClient ? ?? ??????? ?
????? ???? (?????? ?? ?? ??)
UdpClient udpClient new UdpClient(1111)
UdpClient udpClient new UdpClient()
44?????? UdpClient
- Send(byte, int)
- ??????? ????? ? ????? ??? ??????? ?????????????
IP ????? ? ???? - ???? ????????, ?? ??????? ?? ?????????
UdpClient udpClient new UdpClient(
"127.0.0.1", 1111) string msg "Hello" byte
data Encoding.ASCII.GetBytes(msg) udpClient
.Send(data, data.Length)
45?????? UdpClient
- byte Receive(ref IPEndPoint remoteEP)
- ???????? UDP ????? ? ?????
- ????????? ????????
- ???????? ?????????? ?? ????????? ???? ??????????
remoteEP
IPEndPoint serverEP new IPEndPoint(IPAddress.A
ny, 1111) UdpClient udpServer new
UdpClient(serverEP) IPEndPoint senderEP new
IPEndPoint(IPAddress.Any, 0) byte packet
udpServer.Receive(ref senderEP)
46???????????? 5
- ??????????? ???? UdpClient
47?????? WebClient
- WebClient ???? ?????? ?? ???????, ???????? ????
URI ????? - ???????? ???????, ???????? ?? Web
- byte DownloadData(string uri)
- ??????? ???????????? ?? ????????? ?????
- DownloadFile(string uri, string fname)
- ??????? ???????????? ?? ????????? ????? ? ??
??????? ? ????????? ????
WebClient wc new WebClient() byte data
wc.DownloadData("http//www.devbg.org") wc.Downlo
adFile("http//www.devbg.org",
_at_"c\temp\devbg-org.html")
48?????? WebClient
- WebClient ???????? ?????????? ?????? ?? ????????
?????? ??????? - http// Web ???????, ???????? ?? HTTP
- https// Web ??????? (HTTP over SSL)
- file// ??????? ???????
- Headers, ResponseHeaders
- ???????? ???????? ?? ???????? ????? ?? ?????? ???
??????? (WebHeaderCollection)
WebHeaderCollection headers wc.ResponseHeaders
for (int i0 iltheaders.Count i) string
key headers.Keysi string value
headersi Console.WriteLine("0 1",
key, value)
49????????? ?? ????????? ??????
lthtmlgt ltheadgt lt/headgt ltbodygt lt/bodygt lt/htmlgt
http//www.devbg.org
HTTP ??????
HTTP ???????
195.69.120.35 (www.devbg.org)
192.168.0.24 (pesho)
50?????? HttpWebRequest
- HttpWebRequest HTTP ?????? ?? ????????? ??
?????? - ?? ?? ??????? ????????? ?????? ?? ?????????????
WebRequest - ?? ?????? ???? proxy ?????? ?????????? ?????
WebProxy
string url "http//www.devbg.org/" HttpWebReque
st request (HttpWebRequest)
WebRequest.Create(url)
WebProxy proxyServer new WebProxy("193.95.11
2.718080") request.Proxy proxyServer
51?????? HttpWebResponse
- ???? ????? HttpWebResponse ????????? ???????? ??
??????? - Headers ????? ???????? ?? HTTP ????????
- GetResponseStream() ????? ????? ?? ?????? ??
?????? ?? ???????? ?? ???????? - ContentType ????? ???? ?? ???????? ???????
(?????, html, ????????, Flash, ) - StatusCode ???? ?? HTTP ????????
HttpWebResponse response (HttpWebResponse)
request.GetResponse()
Stream stream response.GetResponseStream()
52HttpWebResponse ??????
string url "http//www.devbg.org/" HttpWebReque
st request (HttpWebRequest)
WebRequest.Create(url) HttpWebResponse response
(HttpWebResponse) request.GetResponse() strin
g contentType response.ContentType Console.Writ
eLine("Content-Type 0", contentType) Stream
stream response.GetResponseStream() using
(stream) StreamReader reader new
StreamReader(stream) string responseBody
reader.ReadToEnd() Console.WriteLine(responseBo
dy)
53???????????? 6
- ?????? ? HttpWebRequest ? HttpWebResponse
54????????? ?? ?????? ? e-mail
- Simple Mail Transfer Protocol (SMTP)
- ???????? ?? ????????? ?? e-mail
- ????????? ?? ?????? ??? SMTP ??????
- ??????????? ????? SMTP ???????
- Post Office Protocol, ?????? 3 (POP3)
- ????????? ?? ???????? e-mail ?????????
- Internet Message Access Protocol (IMAP)
- ????????? ?? ???????? e-mail ?????????
- ?????? ??????????? ?? POP3
- ???????? ????? ??? ?????????
- ??????? ?? ??????? ???? ?????? e-mail ???????????
?? ??? ?? ???????
55????????? ? ?????????? ?? e-mail
????????? SMTP ??????? ?? ???? ???????? ?????????!
SMTP
SMTP
POP3 ??????
SMTP ??????
SMTP ??????
SMTP
POP3 IMAP
??? SMTP ?????? ?? ??????????
????????? ?? e-mail
???????? ?? e-mail
56????????? ?? e-mail ? .NET
- ?????? System.Web.SmtpMail
- ?????????? .NET ????????? ??? Windows
???????????? CDOSYS - ?????? ?? ????? CDOSYS (cdosys.dll) ?? ??
?????????? ???? ???? - CDOSYS ? ?????????? ???? ?? Windows 2000, XP ?
2003 - ????????? ?? ???????????? ?? Win98/ME/NT
- SmtpServer ?????? SMTP ???????
- Send(string from, string to, string subject,
string body) ??????? e-mail ?????????
57????????? ?? e-mail ? .N??
- ??????????? SMTP ??????? ?? ????? ????????
?????????, ???????? - smtp.fmi.uni-sofia.bg
- smtp.orbitel.bg
- ?????? ?? ???????? ???? SMTP ??????? ??
?????????? ?? ?? ?????? ?? ??? ??????
string from "dr.ivanov_at_selo-ginci.org" string
to "draganka_at_mangal.net" string subject
"Cool Subject" string body "This is the
message body" SmtpMail.SmtpServer
"smtp.MyISP.com" SmtpMail.Send(from, to,
subject, body)
58?????? ?? e-mail ???????????
- ????? e-mail ????????? ???????
- ???????? ???? ? ???????????????? ?????? (?????)
- ???? ????????? ?????????? ????? (????)
59????????? ?? e-mail ?????????
- System.Web.Mail.MailMessage
- ????????? ????????? ?? ??-?????? e-mail ?????????
- MailMessage.From ??????? ?? ???????????
- MailMessage.?? ?????????? ?? ???????????
- MailMessage.Subject ?????? ?????? ???????
- MailMessage.Body ?????? ???????????? (??????),
????? ????????? - MailMessage.Priority ?????? ????????? (High,
Normal, Low)
60????????? ?? e-mail ?????????
- MailMessage.BodyFormat ?????? ?? ????????????
?? e-mail ??????????? - MailFormat.Html ??????????? ? ? HTML ?????? ?
???????? e-mail ??????? ?? ????? ?? ??
???????????? - MailFormat.Text ??????????? ? ???? ?????
(???????? ?? ????????????) - MailMessage.BodyEncoding ?????? / ???????
?????????? ?? e-mail ??????????? (????????
windows-1251, UTF-8 ? ??.)
MailMessage msg new MailMessage() msg.BodyForma
t MailFormat.Html msg.BodyEncoding
Encoding.Unicode
61????????? ?? e-mail ?????????
- MailMessage msg new MailMessage()
- msg.From "doktor_ivanov_at_selo-ginci.net"
- msg.To "kaka_tonka_at_praseferma.novo-selo.bg"
- msg.Subject "Zdrasti ma!"
- msg.BodyFormat MailFormat.Html
- msg.Body _at_"lthtmlgtltbodygtlth1gtKako, dokaraha
- prasetata. Idvaj burzo!lt/h1gtlt/bodygtlt/htmlgt"
- try
-
- SmtpMail.SmtpServer "mail.interbgc.com"
- SmtpMail.Send(msg)
- Console.WriteLine("Mail sent.")
-
- catch (System.Web.HttpException ex)
-
- Console.WriteLine("Unable to send message
0", - ex.InnerException.InnerException.Message)
62MIME e-mail ?????????
- Multipurpose Internet Mail Extensions (MIME)
- ?????????? ?????? ?? e-mail ????????? (? ??????
?? ?????????) - ????????? ??????????? ?? ??????? ????? ?
???-???????????? ??????? - ??????? ????????? ???????? ???? ????????
????????? ????? - ? ??????? ?? MIME ??????? ????? ?? ?????????
????????? ??????? - ????????, ??????, ???????, PDF ?????????
- ????????? ???????, zip / rar ??????, ....
63MIME e-mail ?????????
- ? MIME ?????????? ???? ?? ????????????
- ???????? ?? MIME ???????
- ???????? ????????????? ?? ???????? ? ?????????
????? - ???????? ?? ???????????? ?? ????????? ?????
- ???????????? ????? ?? ????????
64????????? ?? e-mail ????????? ? ???????? ????
- System.Web.Mail.MailAttachment
- ????????? ?? ??????? ????????? ???? (attachment)
??? e-mail ????????? - MailAttachment(string fileName)
- ??????? ??? ????????? ???? ? ???????? ????????
UUEncode - MailAttachment(string fileName, MailEncoding
encType) - ??????? ??? ????????? ???? ? ???????? ????????
???????? ?? MailEncoding - ????????? ?? ????????? Base64 ? UUEncode
65????????? ?? e-mail ????????? ? ???????? ????
??????
- MailMessage msg new MailMessage()
- msg.From "didi_at_kaval.com"
- msg.To "bobby_at_duduk.net"
- msg.Subject "Hi, Bobby!"
- msg.Body "Here's my picture!!"
- MailAttachment attachment new
- MailAttachment(_at_"c\images\logo.gif")
- msg.Attachments.Add(attachment)
- SmtpMail.Send(msg)
66???????????? 7
- ????????? ?? e-mail ?????????
67??????? ? ???????? ????????????
????????
68??????????
- ??????? 7-?? ???? ?? OSI ???????? ?????.
- ??????? ????? ????????????? ????????? IP ?????,
DNS, ????, ?????? ?????????, TCP, UDP ? ?????
??????. ????? ? ????????? ????? TCP ? UDP
???????????? - ??????? ????????? ??????? ?????? ? ????????,
????? ????????? ????????? ? ??? TCP ???????. - ?? ?? ????????? Windows Forms ??????????
???????????? ?? ?????????????? ???????????
telnet. ???????????? ?????? ?? ????????
????????? ??? ????????? TCP ??????, ????????? ?
???????? ?? ????? ? ?????????? ?? ??????????
????? ??????. ??????????? ?????, ?? ?? ?????????
???????? ?????????????? ??????? ? ?????????? ??
?????.
69??????????
- ???????????? ?????????????????? ?????? ??
????????? (char server). ???????? ?????? ??
?????? ?? ???????? TCP ? ?? ?????????
???????????? ?? ??????????? ? ????????? ??
????????? ????? ?????????????. ????????
???????????? 2 ??????? USER ltusernamegt ? SEND
ltusernamegt ltmessagegt. ???????? ? ???????? ??????.
????????? ????? ??????? ?? ? ????? ???? ???????
??? ? ???????? ?? ????? ??? ????? ??????? 1
??????? ??? ??????? (OK ??? ERR). ?? ?????
?????????? ??????????? 2 TCP ?????? (? 2 ?????,
????? ?? ?? ?????????) ?????? ?? ???????? ??
???????, ? ??????? ?? ????????? ?? ?????????.
???????????, ????? ?? ?? ????????? ???????????? ?
???? ?????? (shared queue).
70??????????
- ???????????? Windows Forms ?????? ?? ??????? ??
????????? (char server) ?? ???????? ??????. - ?? ?? ?????????? UDP ?????? ?? chat ??????? ?
??????? ?? ???? ?????? ?? TCP ?????? ??????
??????? ? ????????? ?????? ?? ?? ?????? ???? UDP
??????. - ???????? Windows Forms ??????????, ?????
????????? ?? DNS ?????? (??????????? ?? ??? ??
?????? ??? IP ????? ? ?????????). - ?? ?? ????????? ??????????, ????? ???????
???????? ???????? ?? ????? http//www.gbg.bg/ ?
????????? ?????? ????????? (hyperlinks). ??
????????? ?? ??????????? ??????????? ????????
????????? ?????.
71??????????
- ?? ?? ?????? ???? (Web-spider) ?? ???????? ??
e-mail ??????. ?????? ?????? ???? ??????? ??
????? URI ????? ? ???????? ? ??????? ????????????
??. ???? ????????? ????????? ?????? ??????? ??
???? ?????? e-mail ?????? ? ?????? ?????????
(hyperlinks). ??????????? ?? ?????????? (????? ??
?? URI ??????) ? ?? ????? ? ???? ??????. ??????
?? ???? ????? ?????? ????????? ?? ????? ?????
???????? URL ????? ?? ????????. ??????? ??
???????? ?? ?? ???????? ?? 50 000. ?? ??-??????
????????????? ?? ?? ?????? ? 10 ?????
????????????. ?? ????????? ?? ????? URI ?????
??????????? ????? WebClient. ?? ??????????? ??
????????? ? ????????? URI ???????????
???????????? ?? Uri ?????.
72??????????
- ?? ?? ??????? ????????, ????? ??????? ??????
e-mail ????????? (???????? ? ??????? ????) ??
?????? ?? ?????????? (???????? ???? ???????
????). SMTP ???????? ? ????????? ?? e-mail
??????????? ?????? ?? ?? ??????? ??
???????????????? ???? ?? ????????????. - ?? ?? ????????? ??????????, ????? ???? ? task
bar ???????? ? ??????? ?? ????? 10 ??????
????????????? ??????? ????, ?? ?????????????
??????? e-mail ?????.
73?????????? ??????????
- ??????? ?????, ???????? ???????????? ? Java,
Faber, 2004, ISBN 954-775-305-3 - Richard Blum, C Network Programming, Sybex,
2003, ISBN 0782141765 - MSDN Training, Programming with the Microsoft
.NET Framework (MOC 2349B), Module 11 Internet
Access - OSI model Wikipedia, the free encyclopedia
http//en.wikipedia.org/wiki/OSI_model