打算看看 C#,听说 Mono 有 Mac OS 支持,下了一个看看,没想到效果还真不错,GNOME 的风格,貌似用的是 GTK+ 的 Mac Port,要比 X11 的界面漂亮不少。
Resource:
Mono Project
打算看看 C#,听说 Mono 有 Mac OS 支持,下了一个看看,没想到效果还真不错,GNOME 的风格,貌似用的是 GTK+ 的 Mac Port,要比 X11 的界面漂亮不少。
Resource:
Mono Project
If you have a dedicated server online can be connected via SSH, you are really lucky. Get tired to search for a workable proxy to access the blocked site? There is a way via the powerful SSH.
Geek to Live: Encrypt your web browsing session (with an SSH SOCKS proxy)
But, if you are a facebook application developer, you must feel very painful to debug the application. Because it requires your application can be accessed by facebook servers, at least you should have public IP address or forwarding the traffic from your router.
Anyway, the problem can be easily solved. Thanks to my friend Wang Chun, he found a way to use SSH creates a tunnel that forwards traffic from server to the client. AWESOME!!
You can use option -R to listen on the port of server and forward the traffic to client.
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side. This works by allocating
a socket to listen to port on the remote side, and whenever a connection is made to this port, the connection is forwarded over the secure channel,
and a connection is made to host port hostport from the local machine.
Port forwardings can also be specified in the configuration file. Privileged ports can be forwarded only when logging in as root on the remote
machine. IPv6 addresses can be specified by enclosing the address in square braces or using an alternative syntax:
[bind_address/]host/port/hostport.
By default, the listening socket on the server will be bound to the loopback interface only. This may be overriden by specifying a bind_address.
An empty bind_address, or the address `*', indicates that the remote socket should listen on all interfaces. Specifying a remote bind_address will
only succeed if the server's GatewayPorts option is enabled (see sshd_config(5)).
Don’t forget to enable ‘GatewayPorts’ in the /etc/ssh/sshd_config.
Enjoy!
今天打开了 lighttpd 得 mod_status,发现居然 fd-Event-Handler 默认用的是 Poll,大吃了一惊。还以为他怎么也会根据平台使用 kqueue 呢。网上搜了一下,找到了配置的方法,不需要重新编译只需要在 conf 里面配置一下。
server.event-handler = “freebsd-kqueue”
当然还可以选择其他,详细的参考 lighttpd wiki 吧。
这两天通过看 C10K 的文章对 kqueue 萌发了比较大的兴趣。于是又温习了一下 C 语言,立即上手学着想写写东西。
说道 kqueue,可以看下之前的 blog,它是在 BSDCON 2000 时候提出来的,是一个 edge-triggered 方式的通知形式。不同与 level-triggered 方式的传统 select() 和 poll(),在 fd 列表数量很大的情况下不至于增加CPU的负担。
kqueue 的 API 设计的相当精简,只有两个新的系统调用,kqueue() 和 kevent()。kqueue() 是初始化环境,kevent() 则是负责了注册和取回事件列表。这两个 API 用起来还是相当方便的,大体上是以 kqueue() 初始化开始,然后使用 kevent() 注册感兴趣的事件和需要监视的条件,再之后就可以用 kevent() 来获得触发的事件了,一般使用一个主循环去处理就可以了。
了解原理之后就可以动手做一下了,Mac OS X 也早就提供了 kqueue 的支持,可以直接用 C 写相关程序进行学习了。
今天又重新读了 The C10K Problam,决定好好写份摘要记录下学到的内容。
文章主要探讨了如何配置操作系统或者编写相应的程序可以支持10K数量级以上的客户端。目前有不少IO框架可供选择使用,譬如重量级的ACE,轻量级的libevent等。
开发网络应用一般有一些好的I/O策略可以参考:
采用哪种通知机制非常关键,主要有两种readiness notification类型,基于level-triggered的方式有传统的select()和poll()系统调用,level-triggered针对file descriptors的condition改变进行通知,一旦condition出现变化,那么用select()系统调用会检测到。而edge-triggered这个概念在BSDCON 2000大会上关于kqueue()的论文里面由Jonathon Lemon提出的,和level-triggered不同的是,这种通知不取决于condition的改变,而是取决于事件源的活动。
下面是引自 Kqueue 这篇论文里面的说明:
Events will normally considered to be “level-triggered”, as opposed to “edge-triggered”. Another way of putting this is to say that an event is be reported as long as a specified condition holds, rather than when activity is actually detected from the event source. The given condition could be as simple as “there is unread data in the buffer”, or it could be more complex. This approach handles the scenario described above, and allows the application to perform a partial read on a buffer, yet still be notified of an event the next time it calls the API. This corresponds to the existing semantics provided by poll() and select().
Recent Comments