글

5월, 2013의 게시물 표시

IPC 참고 링크

IPC 관련 내용을 찾다보니 괜찮은 예제가 있길래 링크를 걸어둔다. IPC 쉬운 예제 이해하기 쉬운 설명되어 있음. http://beej.us/guide/bgipc/output/html/singlepage/bgipc.html 복잡하지만 좋은 예제 존재 http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzab6/rzab6xnonblock.htm

멀티플렉싱 sender 테스트(udp socket, fifo, select)

[참고 :  멀티플렉싱 receiver 테스트 ] 멀티플렉싱 sender 테스트를 위한 코드로 udp socket, select, 그리고 IPC(fifo) 를 썼다. -------------------------------------------------------- sender.c #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/socket.h> // for socket(), bind(), connet() #include <arpa/inet.h> // for sockaddr_in, inet_ntoa() #include <pthread.h> typedef int SOCKET; #define NET_INVALID_SOCKET -1 #define NET_SOCKET_ERROR -1 #define MAXCONN   10 #define MAX_BUF_SIZE 500 #define FIFO_NAME "my_test" int main(void) {     char s[300] = "FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_\ FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_\ FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_TEST_MSG_FIFO_...

멀티플렉싱 receiver 테스트(udp socket, fifo, select)

[참고 :  멀티플렉싱 sender 테스트 ] 멀티플렉싱 receiver(서버 역할) 테스트를 위한 코드로 udp socket, select, 그리고 IPC(fifo) 를 썼다. ---------------------------------------------------------------------------- receiver.c #include <stdio.h>  #include <stdlib.h>  #include <string.h>  #include <errno.h> #include <fcntl.h>  #include <sys/time.h>  #include <sys/types.h>  #include <sys/stat.h> #include <unistd.h>  #include <pthread.h> #include <sys/socket.h> #include <netinet/in.h> #define FIFO_NAME "my_test" #define MAX_FD 2 int main() {    //      int i;         int state;     // for fifo & select int num; int fd[MAX_FD]; char fifo_buf[300]; struct timeval tv; // not used     fd_set readfds, writefds; // for socket int n; int sockfd;     int clilen;     char rcv_bu...