惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - xxp

翻译:Android程序开发入门 php,mysql下中文编码解决方案 asp.net中使用ajax中的三种方式 翻译:xoops搜索功能的使用 发布新软件:史上最轻量级的ORM--EasyDBOperation XOOPS模块开发快速入门中文翻译--索引 XOOPS模块开发快速入门中文翻译(十) XOOPS模块开发快速入门中文翻译(九) XOOPS模块开发快速入门中文翻译(八) XOOPS模块开发快速入门中文翻译(七) XOOPS模块开发快速入门中文翻译(六) XOOPS模块开发快速入门中文翻译(五) XOOPS模块开发快速入门中文翻译(四) XOOPS模块开发快速入门中文翻译(三) XOOPS模块开发快速入门中文翻译(二) XOOPS模块开发快速入门中文翻译(一) 简单的网页内容采集器(C#) 100%男性倾向? 55 为什么? 学习XOOPS的记录
C#网络编程学习笔记1
xxp · 2008-02-25 · via 博客园 - xxp

TCP/IP是什么

一个协议组。

TCP/IP为什么流行?

因为兼容各种底层组网和标准。(俗话说就是各种接线方式和线)

TCP/IP分层

应用层:SMTP FTP Telnet
传输层:TCP UDP (负责传输并保证到达)
网络层: IP (负责定义门牌号和路径)
数据接口: Ethernet、 Serial Line (最接近物理层,用来封装物理层)

=====================

Socket分类(传输层)

1。流式 (Stream) 对应TCP协议
2。数据报式(Gram)对应UDP协议

Socket应用:

当高层协议(如Http协议、SMTP协议)都满足不了你的需求的时候,强烈需要自定义网络传输的时候才用。 否则就用WebRequest,Email,Ftp类库就行啦。

Socket是什么

可以看作是Client到Server的数据通道

Socket的类库

TCPClient、TCPListener

用Socket实现的网络服务

Telnet Http Email Echo

用法--类似于打电话

客户端:

1。建立Socket实例(new 一个出来)
2。通过Connet方法连接到指定服务器
3。通过Send或者SendTo方法发送数据
4。通过Receive或ReceiveFrom方法接收回执数据

服务器端:

1。Bind方法绑定到指定端口
2。用Listen方法侦听请求
3。通过Accept接收客户端Socket
4。处理数据
5。shutdown 并Close Socket

使用到的类:

EndPoint类:

代表一个终端,一般用 地址+端口 来表示。 子类 IPEndPoint用 IP+端口 来表示
获取IPEndPoint:IPEndPoint ipEP=new IPEndPoint(IPAddress,port);

IPAddress类:

获取方式:IPAddress myIp =IPAddress.Parse("192.168.0.1");

Dns类:

域名服务类。(域名服务:把www.fltek.com.cn解析为IP地址的一种服务)
IPHostEntry myhost= Dns.Resolve("www.fltek.com.cn");
(或者 IPHostEntry myhost=Dns.GetHostByName("www.fltek.com.cn");)
IPAddress myIP=myhost.AddressList[0]; 这就获取了上面的IPAddress

常用异常:

SocketException
ArgumentException 参数为空异常
objectDisaposedException Socekt已关闭异常

注意:

同步和异步:

同步表示 Socket没获取完数据就不把控制权交给程序,一直去获取数据;异步可以马上交回给程序。
例子:
同步 Send方法
异步:BeginSend