
C#网络编程
文章平均质量分 72
frombegintoend
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C#获取本机IP搜集整理7种方法
今天打算试着写个小聊天程序,但是要用到获取本机IP,以前从没用过。摆渡百度了一会儿,出于贪心,想把各种获取本机IP的方法给找出来。摆渡+测试了几个小时,于是有了下面的成果,有点小累,但看到这些成果,也很高兴。不一定很全,但也不少了。 ① private void GetIP() { string hostName = Dns.Ge原创 2012-07-04 00:52:23 · 14252 阅读 · 2 评论 -
用正则表达式匹配邮箱地址
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Net; using System.IO; namespace _07正则_匹配邮箱 { class Program原创 2013-07-02 22:04:33 · 4448 阅读 · 1 评论 -
获取本机IP_考虑多网卡的情况
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using System.Text.RegularExpressions; namespace _09获取本机IP_考虑多网卡_ { class Program原创 2013-07-02 22:00:20 · 1174 阅读 · 0 评论 -
C#获取本机的MAC地址
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; namespace _17获取MAC地址 { class Program { static void Main(string[] args)原创 2013-07-02 21:34:14 · 3338 阅读 · 0 评论 -
C#通过编程方式实现Ping
代码是照着书敲的,贴出来方便平时参考 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.NetworkInformation; namespace _20通过编程方式实现Ping { class Program {原创 2013-07-02 21:24:47 · 1409 阅读 · 0 评论 -
C#发送电子邮件
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Mail; using System.Net.Mime; using System.IO; using System.Net; namespace _11发送电子邮件 { class原创 2013-07-02 21:51:57 · 1124 阅读 · 0 评论 -
C#获取局域网中的所有正在使用的IP地址
方法不是很好。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Text.RegularExpressions; namespace _12获取局域网中的所有IP地址 { class Program原创 2013-07-02 21:41:09 · 3929 阅读 · 1 评论 -
C#用正则表达式对IP进行排序
static void Main(string[] args) { string IPs = " 192.168.1.1 202.47.4.6 1.2.3.3 "; Console.WriteLine(IPs); IPs = Regex.Replace(IPs, @"(\d+)", "00原创 2013-07-02 22:19:22 · 2133 阅读 · 0 评论 -
C#获取本机IP且过滤非真实网卡(如虚拟机网卡)
参考了网上的文章,具体地址不记得了。 下面的方法可以过滤掉虚拟机的网卡等无效网卡,进而只留下真实的网卡。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; namespace _15获取本机IP_过滤非真实网卡_ {原创 2013-07-02 21:38:18 · 6726 阅读 · 0 评论 -
C#获得系统打开的端口和状态
实际是通过c#编程方式调用了CMD命令行,然后调用netstat命令,然后将CMD命令的输出流转到了C#控制台程序上。也可以将结果输出到文件。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace _19获原创 2013-07-02 21:31:04 · 3566 阅读 · 0 评论 -
用UPnP穿透内网
参考了网上的一篇类似的文章,使用一个叫做Interop.NATUPNPLib.dll的程序集,实现穿透局域网。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; using NATUPNP原创 2013-07-02 21:13:18 · 6616 阅读 · 3 评论 -
HTTP断点续传下载的原理
要实现断点续传下载文件,首先要了解断点续传的原理。断点续传其实就是在上一次下载断开的位置开始继续下载,HTTP协议中,可以在请求报文头中加入Range段,来表示客户机希望从何处继续下载。 这是一个普通的下载请求: GET /test.txt HTTP/1.1 Accept:*/* Referer:http://192.168.1.96 Accept-Language:zh-cn Accep原创 2013-06-02 17:41:45 · 11515 阅读 · 0 评论 -
获取外网IP
思路是通过WebRequest连接一些网上提供IP查询服务的网站,下载到含有你的IP的网页,然后用正则表达式提取出IP来 class Program { static void Main(string[] args) { Console.WriteLine(GetExportIP()); Console.R原创 2013-07-02 22:24:15 · 976 阅读 · 0 评论