| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 9434 人关注过本帖
标题:计算机
只看楼主 加入收藏
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
struct passwd 结构体成员
程序代码:
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>

int main(void) {

    struct passwd *pw;

    pw = getpwuid(501);                    /*或者是 getpwnam("wzj"); 用来返回一个指向passwd结构体的指针*/

    printf("%s\n",pw->pw_name);     /*用户名*/

    printf("%s\n",pw->pw_passwd);   /*密码,用'*'表示*/

    printf("%d\n",pw->pw_uid);

    printf("%d\n",pw->pw_gid);

    printf("%s\n",pw->pw_gecos);    /*注释字段*/

    printf("%s\n",pw->pw_dir);      /*初始shell*/

    printf("%s\n",pw->pw_shell);

    return 0;
}


[ 本帖最后由 madfrogme 于 2012-9-1 10:51 编辑 ]

The quieter you become, the more you can hear
2012-09-01 09:48
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
gcc -std=c99 hello.c

启用gcc 的 1999 ISO C 扩展

The quieter you become, the more you can hear
2012-09-01 10:05
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
recv(), send() 函数  和 read(), write() 函数很相似,

区别在于最后一个最后一个int flags

flags 有一个可选项是 MSG_WAITALL

它告诉内核只有达到了要求数量的字节之后才返回,所以说如果系统支持这个选项, readn() 就可以参照如下定义

#define    readn(fd, ptr, n)     recv(fd, ptr, n, MSG_WAITALL)


但是就算指定了MSG_WAITALL, 若果有信号产生,或是连接中断,或是socket发生错误,

也不能按要求返回

The quieter you become, the more you can hear
2012-09-01 16:36
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
SYN segment contains only TCP header and IP header.

SYN flooding 也就是在受到服务器的SYN-ACK之后发送RST

The quieter you become, the more you can hear
2012-09-02 11:53
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
A pending error cause a socket to be both readable and writable

connect() 返回0 则表示成功了


[ 本帖最后由 madfrogme 于 2012-9-5 17:11 编辑 ]

The quieter you become, the more you can hear
2012-09-05 15:51
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
EINPROGRESS :
The socket is non-blocking and the connection cannot be completed immediately.

It is possible to  select() or poll() for completion by selecting socket for writing.

After select() indicates writablity,  use getsockopt() to read the SO_ERROR option at

level SOL_SOCKET to determine whether connect() completed successfully( SO_ERROR is zero)

or unsuccessfully (SO_ERROR is one of the usual error codes explaining the reason for the failure).

The quieter you become, the more you can hear
2012-09-05 16:57
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
What happens if our call to connect on a normal blocking socket is interrupted, say, by a caught signal? Assuming the connect is not automatically restarted, it returns EINTR, But, we cannot call connect again to wait for the connection to complete. Doing so will return EADDRINUSE

The quieter you become, the more you can hear
2012-09-06 09:32
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
The Memory Management Unit (MMU) transforms a logical address into a linear address by means of a hardware circuit called a segmentation unit ;
subsequently, a second hardware circuit called a paging unit transforms the linear address into a physical address


[ 本帖最后由 madfrogme 于 2012-9-13 00:03 编辑 ]

The quieter you become, the more you can hear
2012-09-12 22:30
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
一个设备驱动器可以通过两种方法使用DMA,
synchronous DMA and asynchronous DMA.(同步与非同步)
同步DMA的情况下,数据的传输是通过进程的激发,
非同步DMA的情况下,数据的传输是通过硬件设备的激发
同步DMA的一个例子就是一个正在播放音频的声卡。
一个用户态程序将声音数据写入一个设备文件,
这个设备文件和声卡的digital signal processor(DSP)相关联。
声卡驱动器将这些声音数据积累在内核缓冲区里,
同时,声卡驱动器又指示声卡在一个很好的时机
将声音数据从内核缓冲区复制到DSP,它会激发一个中断,
并且设备驱动器检查内核缓冲区是否还有
声音数据,如果有,驱动器再一次激发DMA数据传输

The quieter you become, the more you can hear
2012-09-12 22:53
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
收藏
得分:0 
A logical address consists of two parts:
a segment identifier and an offset that specifies
the relative address within the segment.

The segment identifier is a 16-bit field called the Segment Selector  
while the offset is a 32-bit field.

The quieter you become, the more you can hear
2012-09-12 23:03
快速回复:计算机
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015924 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved