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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - xpoint

Sybase 11.0.3 bcp数据报错! Sybase SQL Server 11.0.x 调优方案...(未完成) Windows Server Family 上安装Office 2000 你在使用Gmail,Wallop,MSN Spaces,Three Degrees吗? 网易的邮箱太慢了,还要别的选择吗? 学了学awk,也算是收获 Microsoft PowerToys for Windows XP 给Windows,SCO,AIX添加静态路由 给博客园的bloger提供若干GMail邀请。(暂放半天,明天移帖) 微软的应用程序块列表 了解POP3协议,使用简单的代码监控pop3邮箱,或者不用代码,直接使用telnet 反射的任务 微软为什么把标准提升的这么快, .Net Framework 1.1-> 2.0,连核心的类库都换了! 让你的gVim支持Miscrosoft Visual C++ 2003 设置一个Label控件上文字的字体样式和字体大小随机的代码 Linux TCP/IP 协议栈源码分析(一) 国外高手参加世界编程大赛时的参赛作品(转载) UltraEdit-32中的小bug。 还是关于《设计模式》
得到本机socket选项的全部默认值。
xpoint · 2004-07-10 · via 博客园 - xpoint

 最近写一些在网络上捕获数据包的程序,用到了RawSocket,其中要用到SetSocketOption()
原型为:
     SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, 1);
第三个参数为什么要是 1 呢?原因是默认的值是 0 ,1表示打开这个选项。
那么还有多少这样的选项呢?答案是:很多,有200项左右。
于是有了下面的代码,它可以看一看你使用socket时每个option的默认值。知道了这些,你就
可以有的放矢的SetSocketOption()了。

namespace SKY.SocketOptions
{
    
using System;
    
using System.Net.Sockets;
    
public class SocketOptions
    
{
        
public static void Main(string[] args)
        
{
            
int count = 0
            
//使用那种构造函数并不重要,何值也不重要,无非是CLR分配一些相关的结构
            
//结构是重要的
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
           
            Type sol 
= typeof(SocketOptionLevel);
            Type son 
= typeof(SocketOptionName);
            Console.WriteLine(
"\t\t num \tLevel Name\t DefaultOption");
            Console.WriteLine(
"----------------------------------------------------------------");
            
            
foreach(string s1 in Enum.GetNames(sol))
            
{
                
foreachstring s2 in Enum.GetNames(son))
                
{
                    count
++;
                
try
                
{
                    SocketOptionLevel o1 
= (SocketOptionLevel)Enum.Parse(sol,s1);
                    SocketOptionName o2 
= (SocketOptionName)Enum.Parse(son,s2);
                    Console.Write(
" \t{0}\t {1:-10}\t {2:-30}",count,s1,s2);
                    
//Get Values
                    Console.Write(" \t\t{0}\n ",socket.GetSocketOption(o1,o2));
                }

                
catch(ArgumentNullException)
                
{
                    Console.Write(
"\t NULL\t ");
                }

                
catch(ArgumentException)
                
{
                    Console.Write(
"\t NULL\t ");
                }

                
catch(SocketException)
                
{
                    Console.Write(
" \tNULL \t");
                }

            }


            }

            Console.WriteLine(
"----------------------------------------------------------------");
            
/*
            Console.WriteLine("-------------SocketOptionLevel---------------------------");
            foreach ( string s1 in Enum.GetNames(sol))
            {
            Console.WriteLine( "{0}",s1);
            }
            Console.WriteLine("-------------SocketOptionName----------------------------");
            foreach( string s2 in Enum.GetNames(son))
            {
            Console.WriteLine( "|{0}",s2);
            }
            Console.WriteLine("------------------END------------------------------------");
            
*/

            Console.ReadLine();
        }

    }

}

下面是屏幕截图