<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>달콤 쌉싸래한 인생 &#187; Programming</title>
	<atom:link href="http://jongsunkim.pe.kr/archives/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://jongsunkim.pe.kr</link>
	<description>Be fully awake if you want to dream</description>
	<lastBuildDate>Sun, 22 Apr 2012 12:02:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>스레드 미니사이트</title>
		<link>http://jongsunkim.pe.kr/archives/1617</link>
		<comments>http://jongsunkim.pe.kr/archives/1617#comments</comments>
		<pubDate>Sat, 07 May 2011 11:51:47 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1617</guid>
		<description><![CDATA[http://www.joinc.co.kr/modules/moniwiki//wiki.php/Site/Thread]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.joinc.co.kr/modules/moniwiki//wiki.php/Site/Thread">http://www.joinc.co.kr/modules/moniwiki//wiki.php/Site/Thread</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1617/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>네트워크에서 구조체 자체를 넘기는 방법</title>
		<link>http://jongsunkim.pe.kr/archives/1611</link>
		<comments>http://jongsunkim.pe.kr/archives/1611#comments</comments>
		<pubDate>Tue, 03 May 2011 06:36:34 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1611</guid>
		<description><![CDATA[http://kldp.org/node/59971]]></description>
			<content:encoded><![CDATA[<p><a href="http://kldp.org/node/59971">http://kldp.org/node/59971</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1611/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fscanf 를 이용한 파일 읽기.</title>
		<link>http://jongsunkim.pe.kr/archives/1609</link>
		<comments>http://jongsunkim.pe.kr/archives/1609#comments</comments>
		<pubDate>Wed, 27 Apr 2011 14:35:02 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1609</guid>
		<description><![CDATA[1 #include &#60;stdio.h&#62; 2 #include &#60;string.h&#62; 3 4 typedef struct { 5     char s1[50]; 6     char s2[50]; 7     char s3[50]; 8     char s4[50]; 9     char s5[50]; 10     char s6[50]; 11     char s7[50]; 12 13 } conf_value; 14 15 int main(void) 16 { 17     char key[50]; 18     char value[50]; 19     char temp; 20     FILE *fp = [...]]]></description>
			<content:encoded><![CDATA[<p>1 #include &lt;stdio.h&gt;<br />
2 #include &lt;string.h&gt;<br />
3<br />
4 typedef struct {<br />
5     char s1[50];<br />
6     char s2[50];<br />
7     char s3[50];<br />
8     char s4[50];<br />
9     char s5[50];<br />
10     char s6[50];<br />
11     char s7[50];<br />
12<br />
13 } conf_value;<br />
14<br />
15 int main(void)<br />
16 {<br />
17     char key[50];<br />
18     char value[50];<br />
19     char temp;<br />
20     FILE *fp = fopen(&#8220;parser.conf&#8221;, &#8220;rt&#8221;);<br />
21     int ret;<br />
22<br />
23     while(1)<br />
24     {<br />
25         ret = fscanf(fp, &#8220;%s %c %s&#8221;, key, &amp;temp, value);<br />
26         if(ret == EOF)<br />
27                 break;<br />
28         printf(&#8220;%s %s\n&#8221;, key, value);<br />
29     }<br />
30<br />
31     fclose(fp);<br />
32<br />
33     return 0;<br />
34<br />
35 }<br />
~</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>fscanf 을 이용해서 파일을 읽어서</p>
<p>원하는 값을 추출한다.</p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1609/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pthread_join</title>
		<link>http://jongsunkim.pe.kr/archives/1599</link>
		<comments>http://jongsunkim.pe.kr/archives/1599#comments</comments>
		<pubDate>Thu, 14 Apr 2011 23:17:56 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[System Programming]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1599</guid>
		<description><![CDATA[pthread_join 는 실별번호 th 로 시작된 쓰레드가 종료되는걸 기다린다. 이러헌 쓰레드의 종료는 pthread_exit(3)로 종료되거나 혹은 리턴되는 경우 발생한다. 만약 thread_return값이 NULL 이 아니라면, th의 리턴값이 저장된 영역이 전달되게 된다. th 식별번호를 가지는 쓰레드가 join 되기 위해서는 반드시 joinable 상태의 쓰레드로 작동하고 있어야지만 한다. 만약 기다리는 쓰레드가 pthread_detach(3) 함수를 통해서 detached 상태가 되었거나 혹은 pthread_create(3)로 실행될때 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>pthread_join</strong> 는 실별번호 <strong>th</strong> 로 시작된 쓰레드가 종료되는걸 기다린다. 이러헌 쓰레드의 종료는  		<strong><a href="http://www.joinc.co.kr/modules/moniwiki/wiki.php/manSearch?google=none&amp;name=pthread_exit">pthread_exit</a>(3)</strong>로 종료되거나 혹은 리턴되는  		경우 발생한다.</p>
<p>만약 <strong>thread_return</strong>값이 NULL 이 아니라면,  		<strong>th</strong>의 리턴값이 저장된 영역이 전달되게 된다.</p>
<p><strong>th</strong> 식별번호를 가지는 쓰레드가 join 되기  		위해서는 반드시 joinable 상태의 쓰레드로 작동하고 있어야지만 한다.  		만약 기다리는 쓰레드가 <strong><a href="http://www.joinc.co.kr/modules/moniwiki/wiki.php/manSearch?google=none&amp;name=pthread_detach">pthread_detach</a>(3)</strong> 함수를  		통해서 detached 상태가 되었거나 혹은  		<strong><a href="http://www.joinc.co.kr/modules/moniwiki/wiki.php/manSearch?google=none&amp;name=pthread_create">pthread_create</a>(3)</strong>로 실행될때  		<strong>PTHREAD_CREATE_DETACHED</strong> 특성으로 실행되었다면  		join 으로 기다릴수 없게 된다.</p>
<p>joinable 쓰레드가 종료되면, 종료된다고 하더라도 즉시  		메모리 자원등이 해제 되지 않는다. pthread_join 함수를 만나야지만  		자원이 해제된다. 그럼으로 모든 joinable 쓰레드에 대해서는  		반드시 pthread_join 을 호출해주어야 한다. 그렇지 않을경우  		메모리 누수가 발생할것이다.</p>
<p>&nbsp;</p>
<p><a href="http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/3/pthread_join?cx=002661009167463862046%3A8oq6cxlfibu&amp;cof=FORID%3A9&amp;q=pthread_join&amp;sa=Search&amp;ie=EUC-KR#969">http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/3/pthread_join?cx=002661009167463862046%3A8oq6cxlfibu&amp;cof=FORID%3A9&amp;q=pthread_join&amp;sa=Search&amp;ie=EUC-KR#969</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1599/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sendto(), recvfrom()</title>
		<link>http://jongsunkim.pe.kr/archives/1596</link>
		<comments>http://jongsunkim.pe.kr/archives/1596#comments</comments>
		<pubDate>Mon, 11 Apr 2011 14:33:34 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[Socket Programming]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1596</guid>
		<description><![CDATA[#include&#60;sys/types.h&#62; #include&#60;sys/socket.h&#62; int sendto(int sock, const void *msg, int len, unsigned flags, const struct sockaddr *addr, int addrlen); sock : 데이터를 전송할 때 사용할 소켓의 파일 디스크립터. msg : 전송하고자 하는 데이터를 저장해 놓은 버퍼를 가리키는 포인터. 이 포인터가 가리키는 버퍼의 데이터가 전송될 것이다. len : msg 포인터가 가리키는 위치에서부터 몇 바이트를 전송할 것인지 그 [...]]]></description>
			<content:encoded><![CDATA[<p>#include&lt;sys/types.h&gt;</p>
<p>#include&lt;sys/socket.h&gt;</p>
<p>int sendto(int sock, const void *msg, int len, unsigned flags, const struct sockaddr *addr, int addrlen);</p>
<p>sock : 데이터를 전송할 때 사용할 소켓의 파일 디스크립터.</p>
<p>msg : 전송하고자 하는 데이터를 저장해 놓은 버퍼를 가리키는 포인터. 이 포인터가 가리키는 버퍼의 데이터가 전송될 것이다.</p>
<p>len : msg 포인터가 가리키는 위치에서부터 몇 바이트를 전송할 것인지 그 크기를 인자로 넘겨준다.</p>
<p>flags : 옵션을 설정하는데 필요한 인자인데 일반적으로 0을 넣어주면 된다. 크게 사용되 않는다.</p>
<p>addr : 전송하고자 하는 곳의 주소 정보로 초기화한 다음에 인자로 넘겨주게 된다.</p>
<p>addrlen : addr 포인터가 가리키고 있는 구조체 변수의 크기를 인자로 넘겨준다.</p>
<p>#include&lt;sys/types.h&gt;</p>
<p>#include&lt;sys/socket.h&gt;</p>
<p>int recvfrom(int sock, void *buf, int len, unsigned flags, struct sockaddr *addr, int *addrlen)</p>
<p>sock : 데이터를 수신할 때 사용할 소켓의 파일 디스크립터</p>
<p>buf : 수신할 데이터를 저장할 버퍼를 가리키는 포인터이다.</p>
<p>len: 수신할 수 잇는 최대 바이트 수이다. 일반적으로 buf가 가리키는 저장소의 크기를 넘지 않는다.</p>
<p>flags : 옵션을 설정하는데 필요한 인자.</p>
<p>addr : 주소 정보 구조체 변수의 포인터를 인자로 넘긴다. 함수 호출이 끝나면, 데이터를 전송한 호스트의 주소 정보로 채워진다.</p>
<p>addrlen : addr 포인터가 가리키는 주소 정보 구조체 변수의 크기를 인자로 전달한다.</p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1596/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>인터넷 주소 초기화</title>
		<link>http://jongsunkim.pe.kr/archives/1594</link>
		<comments>http://jongsunkim.pe.kr/archives/1594#comments</comments>
		<pubDate>Mon, 11 Apr 2011 13:44:56 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[Socket Programming]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1594</guid>
		<description><![CDATA[1. struct sockaddr_in addr; 2. char *server_ip=&#8221;127.0.0.1&#8243;; 3. char *server_port=&#8221;15000&#8243;; 4. memset(&#38;addr, 0, sizeof(addr_len)); 5 .addr.sin_family = AF_INET; 6. addr.sin_addr.s_addr = inet_addr(server_ip); 7. addr.sin_port = htons(atoi(server_port)); &#160; 1. 에서 인터넷 주소 정보를 나타내는 구조체 변수 생성 2. 와 3. 에서 IP 주소와 Port 를 선언 4. 에서 memset 함수를 호출해서 인자로 전달된 구조체 변수를 0으로 [...]]]></description>
			<content:encoded><![CDATA[<p>1. struct sockaddr_in addr;</p>
<p>2. char *server_ip=&#8221;127.0.0.1&#8243;;</p>
<p>3. char *server_port=&#8221;15000&#8243;;</p>
<p>4. memset(&amp;addr, 0, sizeof(addr_len));</p>
<p>5 .addr.sin_family = AF_INET;</p>
<p>6. addr.sin_addr.s_addr = inet_addr(server_ip);</p>
<p>7. addr.sin_port = htons(atoi(server_port));</p>
<p>&nbsp;</p>
<p>1. 에서 인터넷 주소 정보를 나타내는 구조체 변수 생성</p>
<p>2. 와 3. 에서 IP 주소와 Port 를 선언</p>
<p>4. 에서 memset 함수를 호출해서 인자로 전달된 구조체 변수를 0으로 초기화해 주고 있다. 구조체 변수의 모든 멤버를 적절한 값으로 초기화해 주는 경우 모든 멤버를 00으로 초기화할 필요는 없으나, 불필요한 데이터를 쓰레기 값으로 남겨두는 것은 문제의 소지가 될 수 있고, 나중에 디버깅하는데 어려움을 줄 수도 있다.</p>
<p>5. 에서 &#8216;프로토콜 체계&#8217; 설정</p>
<p>6. 에서 IP 주소를 설정해 주는데, 스트링을 네트워크 바이트 순서로 된 32비트 IP 값으로 변환해서 대입해 주고 있다. sockaddr_in의 멤버에는 네트워크 바이트 순서로 값을 대입해야 함을 잊지말자.</p>
<p>7. 에서 atoi 함수를 사용하여 스트링을 정수 값으로 바꿔주고, 다시 htons 함수를 통해 네트워크 바이트 순서로 변환해 주고 있다.</p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1594/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Call</title>
		<link>http://jongsunkim.pe.kr/archives/1587</link>
		<comments>http://jongsunkim.pe.kr/archives/1587#comments</comments>
		<pubDate>Sat, 02 Apr 2011 13:17:48 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[System Programming]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1587</guid>
		<description><![CDATA[fork : 호출 프로세스와 똑같은 새로운 프로세스를 하나 생성한다. fork는 가장 기본적인 프로세스 생성 프리미티브이다. exec : 한 집단의 라이브러리 루틴과 하나의 시스템 호출로, 각각은 동일한 기능 즉, 한 프로세스의 기억공간을 새로운 프로그램으로 대치시킴으로써 프로세스를 변환시키는 기능을 수행한다. exec 호출들 각각의 차이는 그들의 인수 리스트가 어떤 방법으로 작성되는가에 있다. wait : 이 호출은 초보적인 프로세스 [...]]]></description>
			<content:encoded><![CDATA[<p>fork :</p>
<p>호출 프로세스와 똑같은 새로운 프로세스를 하나 생성한다. fork는 가장 기본적인 프로세스 생성 프리미티브이다.</p>
<p>exec :</p>
<p>한 집단의 라이브러리 루틴과 하나의 시스템 호출로, 각각은 동일한 기능 즉, 한 프로세스의 기억공간을 새로운 프로그램으로 대치시킴으로써 프로세스를 변환시키는 기능을 수행한다. exec 호출들 각각의 차이는 그들의 인수 리스트가 어떤 방법으로 작성되는가에 있다.</p>
<p>wait :</p>
<p>이 호출은 초보적인 프로세스 동기화(synchronization)를 제공한다. 한 프로세스로 하여금 연관된 다른 프로세스가 끝날 때까지 기다릴 수 있게 한다.</p>
<p>exit :</p>
<p>프로세스를 종료할 때 사용된다.</p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1587/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java reflectioin exam</title>
		<link>http://jongsunkim.pe.kr/archives/1585</link>
		<comments>http://jongsunkim.pe.kr/archives/1585#comments</comments>
		<pubDate>Mon, 28 Mar 2011 08:52:05 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1585</guid>
		<description><![CDATA[http://java.sun.com/developer/technicalArticles/ALT/Reflection/]]></description>
			<content:encoded><![CDATA[<p>http://java.sun.com/developer/technicalArticles/ALT/Reflection/</p>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1585/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL 주소가 가리키는 파일 읽어서 저장</title>
		<link>http://jongsunkim.pe.kr/archives/1567</link>
		<comments>http://jongsunkim.pe.kr/archives/1567#comments</comments>
		<pubDate>Thu, 03 Mar 2011 14:31:07 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java IO&NIO]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1567</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: java; title: ; notranslate">
package com.test.url;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class URLSaver {
    public static void main(String[] args) {
        if(args.length != 2) {
            System.out.println(&quot;사용법 : java URLSaver URL filename&quot;);
            System.exit(1);
        }

        URL url = null;

        try {
            url = new URL(args[0]);
        } catch (MalformedURLException e) {
            System.out.println(&quot;잘못된 URL 형식입니다.&quot;);
            System.exit(1);
            e.printStackTrace();
        }

        FileOutputStream fos = null;

        try {
            URLConnection urlConnection = url.openConnection();
            InputStream in = urlConnection.getInputStream();

            fos = new FileOutputStream(args[1]);
            byte[] buffer = new byte[512];
            int readcount = 0;

            System.out.println(&quot;읽기 시작&quot;);
            while((readcount = in.read(buffer)) != -1) {
                fos.write(buffer, 0, readcount);
            }
            System.out.println(&quot;파일 저장 완료&quot;);
        } catch (IOException e) {
             e.printStackTrace();
        } finally {
            try {
                if(fos != null) {
                    fos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1567/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Properties Editor for Eclipse</title>
		<link>http://jongsunkim.pe.kr/archives/1539</link>
		<comments>http://jongsunkim.pe.kr/archives/1539#comments</comments>
		<pubDate>Tue, 15 Feb 2011 04:40:25 +0000</pubDate>
		<dc:creator>Kim Jong-seon</dc:creator>
				<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://jongsunkim.pe.kr/?p=1539</guid>
		<description><![CDATA[참고 http://blog.kangwoo.kr/6 이클립스 플러그인 설치 url http://propedit.sourceforge.jp/eclipse/updates]]></description>
			<content:encoded><![CDATA[<p>참고</p>
<p><a href="http://blog.kangwoo.kr/6">http://blog.kangwoo.kr/6</a></p>
<p>이클립스 플러그인 설치 url</p>
<div>http://propedit.sourceforge.jp/eclipse/updates</div>
]]></content:encoded>
			<wfw:commentRss>http://jongsunkim.pe.kr/archives/1539/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

