亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 5056 | 回復(fù): 4
打印 上一主題 下一主題

unix domain socket [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-06-02 14:37 |只看該作者 |倒序?yàn)g覽
linux系統(tǒng)中對(duì)于unix domain socket 的 struct sockaddr_un有一個(gè)字段char  sun_path[],
bind socket時(shí)系統(tǒng)會(huì)自動(dòng)創(chuàng)建這個(gè) sun_path 文件
close socket時(shí)不會(huì)自動(dòng)刪除這個(gè)文件?

論壇徽章:
84
每日論壇發(fā)貼之星
日期:2015-12-29 06:20:00每日論壇發(fā)貼之星
日期:2016-01-16 06:20:00每周論壇發(fā)貼之星
日期:2016-01-17 22:22:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-20 06:20:00每日論壇發(fā)貼之星
日期:2016-01-20 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-21 06:20:00每日論壇發(fā)貼之星
日期:2016-01-21 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-23 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-31 06:20:00數(shù)據(jù)庫(kù)技術(shù)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-16 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2016-01-14 06:20:00
2 [報(bào)告]
發(fā)表于 2009-06-02 21:45 |只看該作者
原帖由 bobozhang 于 2009-6-2 14:37 發(fā)表
linux系統(tǒng)中對(duì)于unix domain socket 的 struct sockaddr_un有一個(gè)字段char  sun_path[],
bind socket時(shí)系統(tǒng)會(huì)自動(dòng)創(chuàng)建這個(gè) sun_path 文件
close socket時(shí)不會(huì)自動(dòng)刪除這個(gè)文件?


不會(huì),
一般寫基于AF_LOCAL的服務(wù)程序,bind前先unlink那個(gè)文件,來(lái)保證bind成功。

可以看看《UNIX環(huán)境高級(jí)編程》和《UNIX網(wǎng)絡(luò)編程》里的介紹

論壇徽章:
1
天蝎座
日期:2013-10-23 21:11:03
3 [報(bào)告]
發(fā)表于 2009-06-02 21:55 |只看該作者
原帖由 yjh777 于 2009-6-2 21:45 發(fā)表


不會(huì),
一般寫基于AF_LOCAL的服務(wù)程序,bind前先unlink那個(gè)文件,來(lái)保證bind成功。

可以看看《UNIX環(huán)境高級(jí)編程》和《UNIX網(wǎng)絡(luò)編程》里的介紹



接一下

17.3.1. Naming UNIX Domain Sockets
……
On Linux 2.4.22 and Solaris 9, the sockaddr_un structure is defined in the header <sys/un.h> as follows:

   struct sockaddr_un {
        sa_family_t sun_family;      /* AF_UNIX */
        char        sun_path[108];   /* pathname */
   };

On FreeBSD 5.2.1 and Mac OS X 10.3, however, the sockaddr_un structure is defined as

   struct sockaddr_un {
        unsigned char  sun_len;         /* length including null */
        sa_family_t    sun_family;      /* AF_UNIX */
        char           sun_path[104];   /* pathname */
   };

The sun_path member of the sockaddr_un structure contains a pathname. When we bind an address to a UNIX domain socket, the system creates a file of type S_IFSOCK with the same name.

This file exists only as a means of advertising the socket name to clients. The file can't be opened or otherwise used for communication by applications.

If the file already exists when we try to bind the same address, the bind request will fail. When we close the socket, this file is not automatically removed, so we need to make sure that we unlink it before our application exits.

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2009-06-03 09:02 |只看該作者
哦,原來(lái)是這樣。。。
我們的一個(gè)設(shè)備,跑了幾十天后突然就跑不動(dòng)了,查了下原來(lái)是/tmp/目錄下已經(jīng)沒有空間了,里面塞滿了tmpnam返回的那種文件名,查了下代碼,共有四個(gè)應(yīng)用程序調(diào)用了tmpnam然后用這個(gè)名字創(chuàng)建了unix domain socket.最后關(guān)閉時(shí)卻忘了刪除對(duì)應(yīng)的那個(gè)文件。

close(sock);時(shí)為什么這個(gè)系統(tǒng)調(diào)用不刪除這個(gè)文件,畢竟這個(gè)文件是由bind()創(chuàng)建的?

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2009-06-03 11:36 |只看該作者
Linux的話,可以使用抽象地址解決(不可移植):
       *  abstract: an abstract socket address is distinguished  by  the  fact
          that  sun_path[0] is a null byte ('\0').  All of the remaining bytes
          in sun_path define the "name" of the socket.   (Null  bytes  in  the
          name have no special significance.)  The name has no connection with
          file system pathnames.  The socket's address in  this  namespace  is
          given  by the rest of the bytes in sun_path.  When the address of an
          abstract socket is returned by getsockname(2),  getpeername(2),  and
          accept(2),  its  length  is sizeof(struct sockaddr_un), and sun_path
          contains the abstract name.  The abstract socket namespace is a non-
          portable Linux extension.
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP