fork함수를 이용한 간단한 서버와 클라이언트 소스입니다 (리눅스환경에서 진행하였고 간단해 이해하기쉽습니다.)
- 최초 등록일
- 2013.05.10
- 최종 저작일
- 2010.09
- 6페이지/ 압축파일
- 가격 1,000원
목차
없음
본문내용
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netdb.h>
#define BUFSIZE 30
void error_handling(char *message);
void z_handler(int sig);
int main(int argc, char **argv)
{
int serv_sock, clnt_sock;
struct sockaddr_in serv_addr;
struct sockaddr_in clnt_addr;
struct sigaction act;
struct hostent *host;
char *temp;
char ipaddrs[20][20];
int n;
int addr_size, str_len, state;
pid_t pid;
char message[BUFSIZE];
if(argc != 2)
{
printf("Usage: %s <port>\n", argv[0]);
exit(1);
}
act.sa_handler = z_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
state = sigaction(SIGCHLD, &act, 0);
if(state != 0)
참고 자료
없음
압축파일 내 파일목록
fork_client.txt
fork_server.txt
과제2.hwp