<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 從 inet_ntoa 看 thread safe 的 API</title>
	<atom:link href="http://blog.hubert.tw/2009/04/18/%e5%be%9e-inet_ntoa-%e7%9c%8b-thread-safe-%e7%9a%84-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hubert.tw/2009/04/18/%e5%be%9e-inet_ntoa-%e7%9c%8b-thread-safe-%e7%9a%84-api/</link>
	<description>Hubert&#039;s Blog</description>
	<lastBuildDate>Mon, 09 Jan 2012 17:40:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: chen3feng</title>
		<link>http://blog.hubert.tw/2009/04/18/%e5%be%9e-inet_ntoa-%e7%9c%8b-thread-safe-%e7%9a%84-api/comment-page-1/#comment-54288</link>
		<dc:creator>chen3feng</dc:creator>
		<pubDate>Wed, 09 Dec 2009 07:21:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hubert.tw/?p=522#comment-54288</guid>
		<description>Winsock 的 inet_ntoa 是threadsafe的，却不是可重入的。
The string returned is guaranteed to be valid only until the next Windows Sockets function call is made within the same thread. 

大致这么做的。

02	inet_ntoa(struct in_addr in) {
03	        static __thread char ret[18];
04	 
05	        strcpy(ret, &quot;[inet_ntoa error]&quot;);
06	        (void) inet_ntop(AF_INET, &amp;in, ret, sizeof ret);
07	        return (ret);
08	}</description>
		<content:encoded><![CDATA[<p>Winsock 的 inet_ntoa 是threadsafe的，却不是可重入的。<br />
The string returned is guaranteed to be valid only until the next Windows Sockets function call is made within the same thread. </p>
<p>大致这么做的。</p>
<p>02	inet_ntoa(struct in_addr in) {<br />
03	        static __thread char ret[18];<br />
04<br />
05	        strcpy(ret, &#8220;[inet_ntoa error]&#8220;);<br />
06	        (void) inet_ntop(AF_INET, &amp;in, ret, sizeof ret);<br />
07	        return (ret);<br />
08	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yv</title>
		<link>http://blog.hubert.tw/2009/04/18/%e5%be%9e-inet_ntoa-%e7%9c%8b-thread-safe-%e7%9a%84-api/comment-page-1/#comment-54216</link>
		<dc:creator>yv</dc:creator>
		<pubDate>Sat, 18 Apr 2009 15:35:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hubert.tw/?p=522#comment-54216</guid>
		<description>最機的是, 這 API, MSDN 說它是 thread-safe: http://msdn.microsoft.com/en-us/library/ms738564(VS.85).aspx
不只這樣, ctime asctime 這類的也是 thread-safe

Microsoft C-runtime 把很多 C-API thread-safe 問題都給搞定...
無形中增加了 Windows program porting 到其他平台的難度啊 (誤)</description>
		<content:encoded><![CDATA[<p>最機的是, 這 API, MSDN 說它是 thread-safe: <a href="http://msdn.microsoft.com/en-us/library/ms738564(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms738564(VS.85).aspx</a><br />
不只這樣, ctime asctime 這類的也是 thread-safe</p>
<p>Microsoft C-runtime 把很多 C-API thread-safe 問題都給搞定&#8230;<br />
無形中增加了 Windows program porting 到其他平台的難度啊 (誤)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

