Skip to content

Commit f663379

Browse files
committed
네트워크 추가 예제
1 parent a25d49a commit f663379

18 files changed

Lines changed: 197 additions & 0 deletions

IO_Multiplexing/ex_select.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct timeval timeout;
2+
timeout.tv_sec = atol(argv[1]);
3+
timeout.tv_usec = atol(argv[2]);
4+
5+
if(select(0, (fd_set *)0, (fd_set *)0, &timeout) < 0) {
6+
printf("select error\r\n");
7+
return FALSE;
8+
}
9+
return TRUE;

IO_Multiplexing/ex_select.c.blog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<pre class="brush:c">struct timeval timeout;
2+
timeout.tv_sec = atol(argv[1]);
3+
timeout.tv_usec = atol(argv[2]);
4+
5+
if(select(0, (fd_set *)0, (fd_set *)0, &timeout) &lt; 0) {
6+
printf("select error\r\n");
7+
return FALSE;
8+
}
9+
return TRUE;
10+
</pre>

IO_Multiplexing/example_fd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define FD_SETSIZE 54
2+
FD_set fdvar
3+
FD_ZERO(&fdvar); // fd_set을 초기화
4+
FD_SET(1, &fdvar); // fd 1비트 검색
5+
FD_SET(4, &fdvar); // fd 4비트 검색
6+
FD_SET(5, &fdvar); // fd 5비트 검색

IO_Multiplexing/example_fd.c.blog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<pre class="brush:c">#define FD_SETSIZE 54
2+
FD_set fdvar
3+
FD_ZERO(&fdvar); // fd_set을 초기화
4+
FD_SET(1, &fdvar); // fd 1비트 검색
5+
FD_SET(4, &fdvar); // fd 4비트 검색
6+
FD_SET(5, &fdvar); // fd 5비트 검색
7+
</pre>

IO_Multiplexing/example_select.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int select(int nfds, fd_set *readfds,
2+
fd_set *writefds, fd_set * exceptfds,
3+
struct timeval *timeout);
4+
FD_ZERO(fd_set *set);
5+
FD_SET(int fd, fd_set *fdset);
6+
FD_CLR(int fd, fd_set *fdset);
7+
FD_ISSET(int fd, fd_set *fdset);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<pre class="brush:c">int select(int nfds, fd_set *readfds,
2+
fd_set *writefds, fd_set * exceptfds,
3+
struct timeval *timeout);
4+
FD_ZERO(fd_set *set);
5+
FD_SET(int fd, fd_set *fdset);
6+
FD_CLR(int fd, fd_set *fdset);
7+
FD_ISSET(int fd, fd_set *fdset);
8+
</pre>

IO_Multiplexing/example_timeval.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct timeval {
2+
long tv_sec; /* seconds */
3+
long tv_use; /* and microseconds */
4+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<pre class="brush:c">struct timeval {
2+
long tv_sec; /* seconds */
3+
long tv_use; /* and microseconds */
4+
};
5+
</pre>

tmn/ex_01.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Switch MANAGED OBJECT CLASS -- 이름을 Switch로 지정
2+
DERIVED FROM "Rec. X.721 | ISO/IEC 10165-2: 1992 :top;" -- 상속 관계 지정
3+
CHARACTERIZED BY
4+
SwitchPkg PACKAGE -- package 이름 지정
5+
6+
BEHAVIOR
7+
SwitchBehavior BEHAVIOR -- switch에 대한 기술
8+
DEFINED AS Instantiable class represnting the switch device;;
9+
10+
ATTRIBUTES -- switch가 가지는 attribute
11+
Switched GET, -- 식별자로서 Get만 허용
12+
NoPorts GET-REPLACES -- 포트의 수로 GET/SET 허용
13+
SwitchName GET-REPACE, -- 스위치 이름 GET/SET 혀용
14+
15+
ACTIONS
16+
PowerOnOff; -- 파워를 끄거나 있음
17+
18+
NOTIFICATIONS
19+
SwitchingAlarm;;; -- Manager에게 통지해야할 내용
20+
21+
REGISTERED AS {switchMObject 1};

tmn/ex_01.py.blog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<pre class="brush:c">Switch MANAGED OBJECT CLASS -- 이름을 Switch로 지정
2+
DERIVED FROM "Rec. X.721 | ISO/IEC 10165-2: 1992 :top;" -- 상속 관계 지정
3+
CHARACTERIZED BY
4+
SwitchPkg PACKAGE -- package 이름 지정
5+
6+
BEHAVIOR
7+
SwitchBehavior BEHAVIOR -- switch에 대한 기술
8+
DEFINED AS Instantiable class represnting the switch device;;
9+
10+
ATTRIBUTES -- switch가 가지는 attribute
11+
Switched GET, -- 식별자로서 Get만 허용
12+
NoPorts GET-REPLACES -- 포트의 수로 GET/SET 허용
13+
SwitchName GET-REPACE, -- 스위치 이름 GET/SET 혀용
14+
15+
ACTIONS
16+
PowerOnOff; -- 파워를 끄거나 켤 수 있음
17+
18+
NOTIFICATIONS
19+
SwitchingAlarm;;; -- Manager에게 통지해야할 내용
20+
21+
REGISTERED AS {switchMObject 1};
22+
</pre>

0 commit comments

Comments
 (0)