최근에 쓴글
-
Login Server
안녕하세요 대학생개발자입니다. 오랜만에 제 원래 전공으로 돌아왔습니다. 오늘은 오랜만에 서버에 대한 포스팅으로 돌아왔는데요. 이전까지는 데이터베이스에 대한 설치와 간단한 쿼리를 익히는게 시간을 쓰느라 포스팅에 지연이 있었습니다. 그럼 시작하도록 하겠습니다. 우선 이전까지는 채팅서버를 만들었었습니다. 일반적으로 우리가 아는 채팅서버라는건 로그인이라는 과정을 통해서 인증을 받은 유저들에 한해서 접근이 가능하도록 설계가 되어있을겁니다. 생각해보면 너무나도 당연한 얘기입니다. 로그인도 하지않은 유저가 채팅서버에 들어와서 채팅 메시지를 보낸다는건 상식적으로 봤을때 정상적으로 보이지 않는 것 같습니다. 반대의 경우도 마찬가지입니다. 로그인도 안한 유저가 로그인이 되어있는 유저의 채팅을 받아 본다는것도 말이안되는건 ..
-
c_4
안녕하세요 대학생개발자입니다. 이번글에서는 반복문에 대해서 간단히 알아보겠습니다. 반복문이란 말 그대로 코드가 반복되는 구간을 의미하는거겠죠... 그리고 거의 모든 반복에는 조건이 있습니다. 우선 반복문에 어떤것들이 있는지부터 봐야할 것 같습니다. 첫번째로 for문이 있습니다. 두번째로 while문이 있습니다. 세번째로 do while문이 있습니다. 먼저 조건문에 공통적으로 들어가는 구성에 대한 얘기를 먼저 해보겠습니다. 1. 초기식 2. 조건식 3. 증감식 조건식에는 위의 세가지 구성이 들어가는데요. 초기식의 경우에는 말그대로 조건식에서 사용될 값을 초기화 해주는 부분입니다. 초기화되지 않은 값을 사용하게되면 visual studio에서는 컴파일 에러를 뱉어주지만 그외 다른 컴파일러에서는 에러를 뱉어주..
-
c_3
안녕하세요 대학생 개발자입니다. 이번 글에서는 이제 모든 코드에 로직이라는것을 결정하는 조건문이나 반복문에 대해서 알아볼거에요. 우선 조건문이라는게 무엇일까요? 말 그대로 어떤 조건에서 실행하고 어떤 조건이 아니면 실행하지 않겠다는 의미로 해석이 되는데요. 우선 조건문은 크게 두가지로 쓰이는데요 첫번째는 if문이고 두번째는 switch문입니다. if문의 경우에는 true와 false로 떨어지는 하나의 명제를 넣어서 그 명제가 참이라면 실행하고 참이 아니라면 실행하지 않는 구문이에요. 물론 if문이라고 해서 꼭 if만 있는건 아닙니다. if 조건에 해당하지 않는 경우에만 실행하고 싶은 부분이 분명 있기 때문에 else라는 키워드도 같이 제공하고 있습니다. if(조건){ 실행블럭 } else{ 실행블럭 } ..
-
c_2
안녕하세요 대학생개발자입니다. 이번글은 저번글에 이어서 C언어에대한 기본 두번째 글입니다. 사실 C언어라는게 막상 접해보면 그렇게 어렵지 않은데 많은분들이 어려운줄 알고계셔요 그래서 어떻게하면 쉽게 설명할 수 있을까 고민하며 적고있습니다. 이번글에서는 자료형에 대한 얘기와 함께 데이터가 실제 어떻게 저장되는지에 대한 얘기를 좀 해볼겁니다. 자료형은 간단히 말하면 어떤 방식으로 이 데이터를 저장할거냐 혹은 표현할거냐 입니다. 저 방식이라는 것에는 다양한게 존재할수있는데요. 첫번째로 데이터를 크기에 따라 나누는 방법이 있습니다. 두번째로 데이터의 종류에 따라 나누는 방법이 있습니다. 먼저 데이터를 크기에 따라 나누는 방법인데요 여러분이 계산기를 사려고 한다고 생각해봅시다. 난 3자리 이상의 연산을 할일이 없..
namespace univ_dev::
-
Login Server
안녕하세요 대학생개발자입니다. 오랜만에 제 원래 전공으로 돌아왔습니다. 오늘은 오랜만에 서버에 대한 포스팅으로 돌아왔는데요. 이전까지는 데이터베이스에 대한 설치와 간단한 쿼리를 익히는게 시간을 쓰느라 포스팅에 지연이 있었습니다. 그럼 시작하도록 하겠습니다. 우선 이전까지는 채팅서버를 만들었었습니다. 일반적으로 우리가 아는 채팅서버라는건 로그인이라는 과정을 통해서 인증을 받은 유저들에 한해서 접근이 가능하도록 설계가 되어있을겁니다. 생각해보면 너무나도 당연한 얘기입니다. 로그인도 하지않은 유저가 채팅서버에 들어와서 채팅 메시지를 보낸다는건 상식적으로 봤을때 정상적으로 보이지 않는 것 같습니다. 반대의 경우도 마찬가지입니다. 로그인도 안한 유저가 로그인이 되어있는 유저의 채팅을 받아 본다는것도 말이안되는건 ..
-
Chatting Server(Multi Thread)
안녕하세요 대학생개발자입니다. 이번글의 목적은 저번글에 이어서 채팅서버에 대한 다 하지 못한 얘기를 해볼까합니다. 이전 글에서 다뤘던 내용이지만 채팅 서버의 구조는 다음과 같았습니다. 메시지를 처리하는 1개의 스레드와 그 외에 IO를 처리하는 워커 스레드들... 그리고 그 워커 스레드들에게서 하나의 큐를 통해 Job을 전달받는 메시지 처리 스레드가 존재했었습니다. 이 구조에서는 메시지 처리 스레드는 메시지가 없으면 큐가 계속 비었는지 있는지 확인하는 방식의 폴링을 채택했었습니다. 물론 이벤트를 이용해서 폴링을 하지 않고 잠들게 할 수 있었지만, 그렇게 하지 않고 그냥 폴링을 통해 하나의 cpu를 계속 사용하도록 만들었었습니다. 이부분에서는 장점도 있고 당연히 단점도 있을겁니다. 우선 장점으로는 구현이 매..
-
NetServer(Chatting Server)
안녕하세요 대학생개발자입니다. 여전히 저는 할일이 많이 남았습니다. 사실 요샌 거의 이론보단 실제 개발에 치중해 있다보니 블로그 글을 쓸 일이 크게 없는것 같습니다. 예전에 LanServer, LanClient 서버와 서버간의 연결에서의 서버, 클라이언트 역할을 하게될 두개의 클래스에 대한 소개를 했었습니다. 이제 시작할 부분은 실제 유저인 클라이언트와 연결을 담당할 외부로 노출될 서버를 개발하게 되었습니다. 뭐... 이름이 바뀌었다고 해서 기능이 크게 달라지진 않았습니다. 대부분의 기능은 LanServer와 동일할겁니다. 뭐... 컨텐츠 쪽의 로직이 많이 달라지겠지만 그건 지금 네트워크 라이브러리에게 중요한것은 아닙니다. 우리가 중요하게 여겨야 할 부분은 네트워크를 타고 흐르는 패킷에 대한 보안입니다...
-
LockFreeStack Trouble Shooting
안녕하세요 대학생 개발자입니다. 락프리에 대한 언급이 있었던지 1주일쯤 지났습니다. 아마 보신분들이 실제로 개발을 해보셨을지는 모르겠습니다만 락프리 알고리즘을 구글링했을때 나오는 의사코드를 보고 코딩을 하셨던분들은 간단히 테스트 해봤을때에는 전혀 문제가 발생하지 않았을겁니다. 하지만 여러 스레드에서 초당 몇백만건의 push, pop을 하게되면 여러 문제가 발생할 수 있는데요. 그럼 시작하도록 하겠습니다. 그래서 무슨문제가 발생하는데? 아마 이 부분이 제일 궁금할 것 같습니다. 저도 이 문제를 찾기위해서 거의 2주일 가까운 시간을 소모하면서 메모리 로그를 봤던 것 같습니다. 사실 이 트러블슈팅의 과정을 올리는게 맞는지 모르겠습니다만... 뭐 이건 제 포트폴리오가 될것이니 이런것도 올려도 상관없을 것 같다는..
-
DumpClass
안녕하세요 대학생 개발자입니다. 이번 글에서는 예외에 대한 핸들링에 대한 부분과 덤프클래스에 대해서 정리를 해보려고합니다. 우리가 0을 분모로 나눗셈을 하려고 하거나 혹은 new에서 메모리가 할당이 되지 않은 이런 경우를 포함 다수 경우에 예외가 발생하게 됩니다. 그리고 이 예외는 c runtime library가 처리를 하거나 혹은 os가 처리할 수 도있겠죠. 우리는 이 예외에대한 모든 핸들링 처리를 우리 코드로 돌리는 작업을 할겁니다. 그리고 예외가 발생했을때 덤프를 남겨 우리가 확인할 수 있게 할겁니다. 그리고 최근 글을 보신분들은 아시겠지만 덤프에대한 구현을 하려는게 아니라 왜 덤프를 써야하는지 왜 에러를 직접 핸들링 해야되는지에 대한 베이직한 이론내용이 들어가지 구현에 대한 부분은 언급하고있지 ..
-
LockFree
안녕하세요 대학생 개발자입니다. 정말 오랜만에 글을 남기게 되었습니다. 한동안 락프리 개발에 시간을 많이 들였습니다.. 사실 락프리라는 알고리즘이 나온지 얼마 안된 기술은 아닙니다. 문서상에 언급되는것만 해도 거의 10년이상된 오래된 기술입니다. 그런데 제가 이런걸 공부하는데 왜 이렇게 오래걸리게 되었냐하면 락프리는 순수하게 멀티스레딩으로 잘 작동되는지 확인이 필요합니다. 사실 만드는 시간보다 검증하고 에러 수정하는 작업에 더 많은 기간을 소모했던것 같습니다. 그리고 락프리 스택과 큐를 사용하기 위해서는 또 다른 문제가 생기는데 이부분에 대해서는 제가 나중에 글을 통해서 언급하도록 하겠습니다. 그럼 시작하겠습니다. 왜 락프리냐? 아마 일반적으로 락프리를 사용하는 경우라면 다음과 같은 경우일겁니다. 너무 ..
-
Network Library - LanServer,LanClient
안녕하세요 대학생 개발자입니다. 마지막 글을 올리고 나서 아주 오랜 시간이 흘렀습니다. 사실 이 테스트를 올릴까 말까 고민을 했었는데 말입니다... 이 내용은 새로운 지식이라기보다는 제가 만든 서버에 대한 구현만 있기 때문에 따로 올릴까 말까 고민했었는데 말입니다... 그래도 일단은 쓰기로 했습니다... 이번 글은 그냥 저 혼자 끄적이는 느낌이 강하고 따로 새로운 지식이 들어가는 부분도 아니기 때문에 크게 고민 없이 술술 읽으셔도 될 것 같습니다. 그리고 가장 중요한 점... 크게 유익 한글은 아닐 겁니다. 직전 글에서는 IOCP에 대한 주의사항과 문제가 될 수 있는 점을 정리했었습니다. 그리고 한동안 그를 바탕으로 주의하며 에코 더미 테스트를 했었습니다. 추가로 서버와 서버 간 통신을 하기 위한 서버 ..
-
MMO_TCPFighter
안녕하세요 대학생 개발자입니다 이번글에서는 저번에 AsyncSelect 모델로 만들었었던 클라이언트의 서버를 만들어 볼 예정입니다. MMO식으로 바꿔서 약 7천명의 더미 봇들을 넣고 테스트를 해볼겁니다. 소켓 모델에 대해서 소개를 해야겠습니다. MMO라고 하면 일반적으로 IOCP를 떠올리시겠지만... 이번프로젝트는 여전히 싱글스레드 + select모델입니다. (왜냐... 아직 멀티스레드에 대한 언급을 안했기 때문에) iocp의 구현이 안됩니다. 그리고 select모델을 이용해도 7000명수용...뭐 큰 문제 없었습니다. 간단한 클라이언트 수정부분에 대해서만 설명드리고 본격적으로 서버에 대한 내용으로 넘어가겠습니다. 우선 클라이언트 기존의 경우에는 MO방식이었죠... 그래서 맵 크기도 640 480 이었습..
-
Chatting Server
안녕하세요 대학생 개발자입니다. 요새 날씨가 많이 춥습니다... 어디 나갈때마다 손발이 얼어붙을거같은데요 역시 이런날에는 집에 짱박혀서 코딩이나 하면서 블로그 쓰는게 제일 좋은거 같아요 그럼 시작하도록 하겠습니다. 이번 글에서 제가 다뤄볼 내용은 채팅서버입니다. 채팅서버는 서버 중에서 가장 난이도가 쉬운 서버중 하나인데요... 이유가 채팅의 경우에는 온 데이터를 따로 가공하지 않고 그대로 돌려보내는 에코서버와 비슷한 방향으로 구현이 되기 때문입니다. 물론 채팅도 중간에 내용을 변경해야되는 경우가 있다면 변경해야되겠지만(욕설 필터링 과같은) 이번 서버에서는 그런게 없기 때문에 그냥 온 패킷 그대로 돌려주는 경우가 많았습니다. 그리고 가장 중요한것은 채팅서버는 온 경우 바로 그자리에서 반응을 취하는 구조이기..
-
Red-Black tree delete
안녕하세요 대학생개발자입니다. 저번 글에 이어서... 레드블랙트리에 대해서 얘기를 해보려고 합니다. 생각보다 포스팅간의 텀이 길어졌는데요... 제가 실수로 다만들어놓고 삭제를 해버리는바람에 ^^... 다시만들었답니다^^^^ 그래도 다행인게 한번 만들어 보니까 그다음에 만들때는 금방 만들더라구요... 그와 동시에 이해도도 조금 상승한 것 같습니다... 바로 시작하도록 하겠습니다. 우선 삭제과정까지는 이진탐색트리와 동일합니다. 삭제노드의 자식이 하나이하일 케이스에서는 자기 노드를 바로 삭제하고 아래노드로 연결시켜주면 끝납니다. 삭제노드의 자식이 둘일경우에는 - 오른쪽 자식중 가장 작은 노드를 삭제하면서 그 값을 타겟에 넣거나 - 왼쪽 자식중 가장 큰 노드를 삭제하면서 그 값을 타겟에 넣는 방법이 있습니다. ..
-
Red-Black Tree (basic + insert)
안녕하세요 대학생개발자입니다. 휴... 요새 한창 매우 바쁘다가 한꺼번에 과제가 해결되버렸습니다... 예전에 제가 안된다고 했던 과제있죠?? 그게 레드블랙 트린데 말입니다... 사실 레드블랙트리를 아직도 100%이해했다고 자신하지 못하겠습니다ㅠㅠ... 물론 하나하나의 케이스를 놓고보면 어떻게 노드가 움직여야 되는지 어떤색으로 칠해져야되는지 알겠지만 그게 코드로 나오는데까지 시간이 상당히 오래 걸리더라구요... 아마... 이번 레드블랙 트리는 2번에 걸쳐서 나눠서 하게될 것 같습니다. 당연하게도 삽입과 삭제의 과정이 너무 케이스가 많기때문에 긴 글이 될 것같습니다. 실제로 다른글들도 읽어봤지만 한큐에 다 정리하기에는 양이 너무 많아보였고... 제가 실제로 메모장에 정리하면서 봤을때도 상당한 양이였기 때문에..
-
Jump Point Search PathFinding Algorithm
안녕하세요 대학생 개발자입니다. 이번 글에서는 저번글에서 약속했던것과 같이 Jump Point Search(이하 JPS)를 다뤄볼 예정입니다. 저번 시간에는 A* 알고리즘을 통해서 휴리스틱 추정값을 통해서 탐색해나갈 방향성에 대해서 제시를 했었는데요. 우리가 일반적으로 알고리즘에서 느리다고 하는 부분은 기본적으로 정렬, 삽입, 삭제, 탐색 등이 있습니다. 하지만 A*의 경우에는 priority queue를 써야하기 때문에 정렬은 빠질수가 없습니다. 혹은 pq가 아니라 리스트를 써서 매번 가장 F값이 작은걸 골라 낸다고 하더라도 그만큼의 시간 소요는 없어서는 안되는 것이라는 거죠. 그렇다면 우리가 줄일수 있는것은 중간에 거쳐가는 노드의 생성을 줄이는 겁니다. 물론 노드의 생성을 줄인다는게 메모리 풀링을 통..
-
A* Path Finding Algorithm
안녕하세요 대학생 개발자입니다. 정말 오랜만에 블로그에 글을 남기는 것 같은데요... 이번 글에서는 길 찾기 알고리즘에 대해서 얘기를 해보려고 합니다. 길찾기 알고리즘은 길을 찾는 알고리즘이죠 말그대로 대신 시작점과 끝점이 주어졌을 때 가장 최단거리를 찾아주는 알고리즘이 되겠습니다. 게임을 플레이할때 분명히 벽넘어를 클릭했는데 벽을 피해서(우회해서) 목적지에 도착하는(+최단거리로) 그런 경우를 많이 보셨을 겁니다. 이런경우에는 길찾기 알고리즘에 의한 행동으로 보시면 될 것 같습니다. 그러면 바로 알고리즘에 대한 얘기를 해보겠습니다 먼저 이번글에서 소개할 녀석은 바로 A*입니다. 대부분 게임에서 에이스타를 많이 사용합니다( 물론 지금은 많이 느리기때문에 에이스타보다 더 좋은 길찾기 알고리즘으로 넘어갔습니다..
-
ObjectFreeList
안녕하세요 대학생개발자입니다. 오늘은 메모리풀과 오브젝트풀, 프리리스트에 대한 얘기를 해보려고합니다. 우선 메모리풀과 프리리스트에 대한 기본적인 이론이 필요할텐데요. pool을 사전에 돌려보면 그냥 수영장이죠... 즉 물을 담아놓는 곳입니다. 여기의 메모리풀또한 메모리의 수영장과 동일합니다. 메모리를 담아놓는 공간이 되는것입니다. 그리고 필요한 메모리를 꺼내서 쓰고 다시 갖다놓을 수 있는거죠 마치 여름엔 물을 가득채워서 물놀이를 하고 겨울에는 텅텅비워놓는것 처럼요. 그럼 간략하게 메모리 풀이 뭔지 감정도는 잡았습니다. 이제 메모리풀이란게 왜 필요한지 설명을 드리려고하는데... 사실 너무 당연한거여서... 이걸 적어야하나 싶습니다. 제일 일차적인 목적은 당연히 할당과 반환에 쓰이는 오버헤드를 줄이기 위함입..
-
Serializing Buffer
안녕하세요 대학생 개발자입니다. 이번 글에서는 직렬화 버퍼에 대해서 얘기를 해보려고합니다. 지금까지 제가 TCP 프로토콜을 이용한 간단한 스트리트 파이터 같은 게임을 만들어봤는데요... 사실 이정도면 나름 완성이 되어있는 상태라고 봐도 무방합니다. 왜냐하면 사실 플레이어가 서버에게 보낼 수 있는 프로토콜은 전부 5바이트로 확정되어있기 때문이고 (이때문에 사실 링버퍼의 의미도 크게 없긴함) 5바이트로 되어있기 때문에 그냥 버퍼를 5바이트 잡고(char [5]같은걸로요) 그걸 패킷이라고 전달해줘도 되기 때문입니다. 하지만 큰 게임들은 가변 길이 버퍼를 많이 사용하게 되는데요... 가변길이 버퍼를 사용하게 되면 좋은점은 당연하게도 너무 큰 버퍼를 잡지 않아도 된다는 장점이 분명 있습니다. 우선 당장은 직렬화 ..
-
WSAAsyncSelect로 게임클라이언트 제작
안녕하세요 대학생개발자입니다. 최근 어마어마한 과제와 어마어마한 일들로 인해서 포스팅을 하지 못했습니다. 드디어 과제가 끝나서 이 과제에 대한 포스팅을 해보려고 하는데요... 이번 글에서는 AsyncSelect 모델을 이용한 게임 클라이언트를 만들었고 그에대한 정리를 해볼겁니다. 이전에 말씀 드렸듯 AsyncSelect 모델은 최근 개발에서는 잘 사용하지 않는 모델입니다. WinMain에 상당히 종속적이고 싱글스레드에서 사용하기 좋기 때문입니다. 뭐 이런 내용은 지금당장 크게 중요한 부분은 아니니 실제 개발부분으로 들어가겠습니다. 시작하겠습니다 먼저 게임에 대한 프로토콜인데요. 일단 프로토콜은 예전의 별 찍기를 만들었던 것과 거의 비슷하게 될 것 같습니다... 우선 프로토콜은 두 종류로 나눠서 사용하고있..
-
WSAAsyncSelect 그림그리기 클라이언트
안녕하세요 대학생개발자입니다. 이번에는 WSAAsyncSelect를 이용한 공유 그림판 클라이언트를 하나 만들어 봤어요. 사실 이벤트 드리븐이란게 진행도를 따로 그리기가 힘들어서 그냥 구조를 말로 설명드릴게요. 우선 내가 만든 소켓이랑 윈도우에 UM_NETWORK라는 메세지와 플래그로 FD_CONNECT, FD_CLOSE, FD_WRITE, FD_READ 정도를 async select하게 만들었습니다. 위쪽 소켓 초기화 부분은 비동기 소켓 하나 만들고 그냥 아이피 하나 읽어와서 연결하는 부분이라 따로 적진 않겠습니다. 네 뭐 이정도만 올려도 되겠죠? 우선 링거로 Time wait을 없애버렸고 WSAAsyncSelect로 메시지를 등록했습니다. 다음으로 이작업이 끝나게 되면 메시지를 기다렸다가 메시지가 뜨..
-
WSAAsyncSelect
안녕하세요 대학생개발자입니다. 이번글에서는 AsyncSelect모델을 가지고 같이 그림을 그릴수 있는 보드를 만들어봤는데요... 우선 AsyncSelect가 뭔지 부터 간단히정리하고 가겠습니다. AsyncSelect 말그대로 select를 비동기적으로 수행한다는겁니다. select를 비동기적으로 한다는건 무슨의미일까요... 음... 일단 select를 다시한번 말씀드린다면... 게임에서의 select서버는 프레임에 맞춰서 루프를 계속 돌면서 폴링을 하는 방법이라고 정리를 했었습니다. 그럼 비동기 select니까 얘도 폴링을 하는 식으로 만들겠구나 라고 생각할 수 있는데요. 음... 사실 이부분에서 select와 async select모델은 전혀 다릅니다. async select의 경우에는 폴링기법으로 로..
-
링 버퍼
안녕하세요 대학생 개발자입니다. 오늘은 링버퍼에 대해서 다뤄볼 예정입니다. 우선 시작하기 전에 게임서버에 링버퍼가 왜 필요한지에 대해서 간단히 설명해야될 것 같습니다. 게임서버는 당연히 빠른 속도와 안정성이 생명입니다. 안정성의 경우에는 모든 케이스에 에러체크를 하고 꼼꼼히 코드를 짜도 터지는 문제긴 하지만... 속도의 경우에는 다른데요... 어쩔수 없이 사용해야 되는 큰 코스트를 가진 함수들 가령... 입출력에 관련된 함수들, 혹은 매우 큰 로직, 했던 코드의 반복 이런 다양한 경우가 있을건데요 이번에 생각해볼것은 어쩔수 없이 사용해야 되는 큰 코스트를 가진 함수들에 대해서생각을 해볼겁니다. 우리가 socket io를 하게되면 어쩔수 없이 호출하는 함수중 가장 많은 비중이 차지하는 함수가 아마 send..
-
select를 이용한 별움직이기 서버
안녕하세요 대학생 개발자입니다. 음... 마지막으로 올렸던 글에서는 별 움직이기 클라이언트에 대한 정리를 했었는데요 오늘은 서버에 대해서 정리를 해보려고 합니다...(오늘 테스트 하는데 혹시 서버가 죽을까... 무서웠습니다) 프로토콜은 이전과 동일합니다. 대신에 다른점은 그냥 이번에는 메세지 안에 헤더가 포함되어있다는 점 뿐??... 뭐 코드에서 아주조금만 달라지면 똑같은 결과로 나오니까... 뭐 특이점은 없습니다. 먼저 얘도 TCP 소켓하나 만들어서 리슨소켓으로 쓸거구요. +논블로킹 소켓으로 만들어줄겁니다. +서버의 경우에는 linger를 이용해서 time_wait을 없엘겁니다. 그외에는 특이사항이 없기 때문에 따로 코드를 올리진 않을거구요. 먼저 서버의 로직의 경우에는 클라이언트와는 좀 다를겁니다. ..
-
select를 이용한 별움직이기 클라이언트
안녕하세요 대학생 개발자입니다. 이번 글에서는 과제였던... select를 이용해서 별움직이기 클라이언트를 만들어서 서버에 연결을 해보려고합니다.(물론 잘되야겠죠 ㅋㅋㅋ) 먼저 당연히 서버와 통신을 하려면 L7에서의 프로토콜이 필요합니다. 그럼 프로토콜을 잠시 보겠습니다. 네 메세지는 이렇게 생겼습니다. 일단 우선 Header가 있는데... 이건 제가 구현을 할때 Header로 buffer를 가르키고 Msg...를 가지고 buffer+4부분을 가르키게 구현했기 때문에 모든 메세지에 헤더가 붙지 않았습니다... 아 그리고 헤더에 보시면 not_used라는 항목이있는데요... 이게 원래 프로토콜에 따라서 사이즈가 다른경우가 대부분이겠지만 지금의 경우에는 제가 링버퍼를 구현을 못한 상태입니다. 그래서 아직 프..
multi thread
-
Thread Design3과 잡다한얘기
안녕하세요 대학생 개발자입니다. 저번 글에서는 IO를 완료한 스레드가 직접 로직에 개입을하는 그런 스레드 디자인을 알아봤습니다. 그리고 IO스레드와 따로 메시지를 처리하는 스레드와 월드의 프레임을 돌려주는 스레드를 분리한 디자인과의 차이점도 확인을 했었습니다. 그리고 가장 중요한 어떤 디자인이 더 효율적이고 더 좋은 디자인인지에 대한 논의를 해봤었습니다. 이번글에서는 헤테로 지니어스와 호모 지니어스에 대한 얘기를 해볼겁니다. 물론 이얘기는 진작 언급 했어야 됬지만 이때까지의 구조는 거의 모두 호모지니어스에 가까운 구조였습니다. 먼저 그럼 시작에 앞서서 이부분에 대해서 짚고 넘어가겠습니다. 워커 스레드들이 있을 때 우리는 이 워커 스레드들이 어떠한 작업을 할지 알려줘야 됩니다. 하나의 스레드는 하나의 함수..
-
Thread Design2
안녕하세요 대학생 개발자입니다. 저번 글에서는 쓰레드 디자인에 대해서 좀 정리를 해봤었습니다. 우선 이전 글에서는 이런 내용들이 있었습니다. 베이스는 무조건 멀티스레드 IOCP로 송수신 처리를 하는 겁니다. IO처리(비동기 recv겠죠)가 완료된 후에는 일거리(잡)들을 업데이트 서버의 큐에 넣어주는 방식이었습니다. 그럼 업데이트를 하는 서버는 큐에서 하나씩 꺼내서 사용하는 방식으로 작동했었는데요. 여기서 서버 월드를 돌리는 메인루프 스레드와 메시지 처리부 스레드가 하나였기 때문에 싱글스레드 서버라고 했었습니다. 그리고 만약 서버에 부하가 큰 로직(길찾기, 물리엔진, AI등)을 처리할땐 그 쓰레드를 분리한다고 했습니다. 추가로 그 쓰레드는 메인 루프를 처리하는 쓰레드에게 최소한의 부하를 주기 위해서 조력하..
-
Thread Design
안녕하세요 대학생 개발자입니다. 저번 글에서는 피터슨 알고리즘을 끝으로 마무리를 지었었는데요... 이번 글에서도 피터슨 알고리즘에 대해서 조금 마무리를 짓고 나서 스레드 디자인으로 넘어가 보겠습니다. 피터슨 알고리즘이란 이런 것이죠. 언어적 차원에서의 논리적인 문제가 전혀 존재하지 않음에도 불구하고 cpu의 out of ordering excution에 의해서 load와 store의 순서가 뒤바뀌게 되고 그 뒤바뀜으로 인해서 결과가 이상해지는 그런 경우였던 거였죠... 근데 이 부분은 고칠 수 있을 것 같이 들립니다. { flag0 = true turn = 0; while(flag1 == true && turn == 0); } 바로 위 코드에서 문제가 되는 상황인 flag1이 load 되는 게 turn의..
-
Out Of Ordering Excution
안녕하세요 대학생 개발자입니다. 저번 글에서는 동기화와 관련된 얘기를 계속 했었습니다. 이번글에서는 out of ordering excution에 대한 정리를 할겁니다. 우선 저 글을 정리하기 이전에 저번 글에서 마져 다 소개하지 못했던 내용들을 정리해놓고 시작하도록 하겠습니다. 저 그럼 시작하겠습니다. Event에 대한 얘기를 하고서는 마감을 했었던 것으로 기억합니다. 어떤 함수를 동기로 처리한다 라고 하면 이런 구조로 처리가 됩니다. ----|A:(return)|---- 저 사이구간은 다른 작업을 하지 못하고 A라는 함수에만 매달려 있어야 하므로 동기 함수라고 할 수 있죠. 근데 이걸 비동기화 시키고 싶다면 예전 같은 경우에는 ----(AThread생성)----- ---(A)---(return) 와 ..
-
Synchronization2
안녕하세요 대학생 개발자입니다. 저번 글에서는 동기화에 대한 얘기와 동기화 객체에 대한 얘기를 간단히 했습니다. 오늘할 얘기도 별반 다르지 않습니다. 다만 다른점은 이번에 다룰 WaitOnAddress는 객체는 아니라는점이죠 ㅋㅋㅋㅋㅋ 주소를 가지고 기다리는 거니까... 객체는 아니잖아요? 어째뜬 시작해보도록 하겠습니다 WaitOnAddress가 뭔지 간단히 파헤쳐 보겠습니다. WaitOnAddress 방식의 동기화는 동기화 객체의 방식처럼 뭔가를 획득하고 안되고라는 개념은 아닙니다. 나는 어느 주소를 대상으로 기다리고 있을테니 니가 준비가 되면 나를 깨워줘의 느낌입니다. 네 그리고 WaitOnAddress의 경우에는 이 하나만 가지고는 동기화를 보장할 수 없습니다. 왜냐면... 주소를 기준으로 기다리기..
-
Synchronization
안녕하세요 대학생 개발자입니다. 오늘은 시간이 많이 남아서 두번째글을 연달아서 쓰고있습니다. 이런날이 언제쯤 또 올수있을지... 한동안 해야할 일이 너무 많았기 때문에 바빳는데... 좋습니다 그럼 시작하겠습니다 저번 글에서는 쓰레드에 대한 얘기를 했었습니다. 쓰레드를 사용할때 어떤점을 주의해야되고 어떤점이 있으니 참고해야된다고 말씀드렸었는데요... 이번시간에는 쓰레드들간에 같은 공유자원을 사용할 때 어떤식으로 공유자원의 동기화를 걸 수있는지 몇가지 방법에 대해서 소개를 할겁니다. 그리고 동기화를 하는 알고리즘 몇가지를 소개할 예정입니다. 자 그러면 시작하겠습니다. 먼저 cpu차원에서의 동기화인 인터락 함수에 대해서 알아보겠습니다. 인터락이라는 것은 먼저 아주 간단하게 보자면 최소단위의 연산을 cpu가 보..
-
Thread
안녕하세요 대학생 개발자입니다. 저번 글에서 동기화 객체에 대한 얘기를 했고 조금 짧은 글이었습니다.왜냐면... 이번글부터 쓰레드 부분인데 사실 쓰레드 부분에 들어가는 순간 어디서 끊어야할지 매우 난감하기 떄문에 중간에 한번 끊고 갈 수 밖에 없었던 부분입니다... 그리고 이번글을 시작하기전에 이번글의 표지사진은 이번글과는 관계가 없음을 알려드립니다. 멀티쓰레드에 대한 얘기를 해야되는데 아직 쓰레드에 대한 얘기도 못꺼냈습니다 ㅋㅋㅋ... 무려 4번째 글만에 드디어 쓰레드라는 제목을 달고 나왔긴 하지만... 사실 이글에서 쓰레드에 대한 모든부분을 다루지는 못할거에요... 그럼 일단 시작해보겠습니다.윈도우는 쓰레드 스케쥴링을 하는 os입니다. 물론 요새는 거의 대부분os가 쓰레드를 스케쥴링하는것으로 알고있습..
-
Synchronization object
안녕하세요 대학생 개발자입니다. 제가 졸업하기까지 이제 거의 한달정도 남았는데 닉네임을 뭐로 바꿔야하는지 참고민이 많습니다... 그것보다 닉네임은 그렇다 치더라고... 블로그 주소는 어찌합니까... 이런 고민들이 참 많습니다... 째뜬 이건 중요하지 않습니다 중요한건 오늘 할 내용이겠죠 자 보면 저번 글에서까지 윈도우즈의 스케쥴링과 컨텍스트 스위칭에 대해서 간단히 알아봤습니다. 저부분에 관한건 계속 언급될겁니다 매우 중요하기 때문이죠... 일단 동기화 객체에 얘기하기 전에 동기화 객체가 왜 필요한지에 대한 언급이 먼저 나와야 될 것 같습니다. int g_Counter; void WorkerThread() { for(int i=0; i< 1000000 ; i++) g_Counter++; } 이런 코드가 있..
-
windows scheduling
안녕하세요 대학생 개발자입니다. 이번 글에서는 저번 글에 이어서 윈도우즈의 스케쥴링 방식에 대해서 얘기를 더 해볼겁니다. 우선 스케쥴링이란게 뭔지 알아야될겁니다. 스케쥴링이란건... 뭐 간단히 따지면 어떤 쓰레드를 실행할 것이냐에 대한 부분인거겠죠 스케쥴링의 주체가 누구인지를 먼저 알아야 될 것 같은데요... 사실 윈도우가 스케쥴링 한다가 맞는말이겠지만... 좀더 구체적으로 어떤 계기로 스케쥴링이 발생하느냐 그리고 누가 직접 스케쥴링을 하느냐 에 대한 부분을 따지고 든다면 cpu자체가 스케쥴링의 주체이자 대상이 될겁니다. 무슨말인지 잘 이해가 안되실 수도있습니다. 간단히 설명하면 os는 코드에 불과합니다 결국 코드라는건 하드웨어 의존없이 혼자서 작동될 수 없는 것인데요... 결국 os의 스케쥴링이란것도 ..
-
Windows preemptive priority based round-robin scheduling
안녕하세요 대학생 개발자입니다 이전 글에서는 싱글 스레드로 구현할 수 있는 간단한 mmo타입의 게임을 만들어봤습니다. 이번 글에서는 게임 서버 개발자가 되면 주로 접하게될 Windows Server, 즉 Windows OS에 대한 얘기를 해보려고합니다. os에 따라 내용이 다른 부분이 있을 수 있으니, 미리 Windows를 상정하고 말씀드린다는 부분 양해부탁드립니다. preemptive 우선 선점에 대한 개념부터 정리를 하고 넘어가겠습니다. 우선 우리가 일반적으로 사용하는 windows os는 선점형이냐 비선점형이냐 라는 부분인데요. 하지만 이 전에 우리가 먼저 따져봐야할 부분이 있습니다. 선점의 주체가 누가 되는것인가 입니다. OS가 선점의 주체가 된다면 스레드들은 OS의 관리를 받는 주체가 될 것입니..
TCP/IP 이론 기초
-
L4에 대한 정리2
안녕하세요 대학생개발자입니다. 이번글에서는 L4에 대한 정리를 또 해보려고 합니다. 저번글에서는 거의 TCP에 대한 얘기를 주로 했었었습니다. UDP에 대한 아주 짧은 내용과함께요. 이번 글에서는 TCP에 이어서 UDP에 대한 내용을 좀 정리하며 L4를 마무리 해볼까 합니다. 뭐.. 다들 아시겠지만 L4 스위치에는 공유기가 있습니다. 공유기가 어떻게 L4 스위치 역할을 하는가... 저는 사실 공유기는 L3기기인 줄 알고 있었는데 L4기기인 것 같더라구요. 왜냐면 공유기는 IP도 변경하지만 포트까지 변경해버리기 때문에 L4기기가 맞습니다. 우리가 데이터를 내보내면 공유기는 내부에서 dynamic port forwarding table을 만들어서 거기에 자신의 공인 아이피:포트 와 사설 아이피(호스트):포트..
-
L4에 대한 정리
안녕하세요 대학생 개발자입니다. 이번엔... 음... L4입니다. 어쩌다 보니 그냥 순서대로 쭉 올라가는 중이네요... 이때까지 했던걸 아주 간략하게 적어보겠습니다. L2는 직접 연결된 두 개의 기기간 통신을 정의해놓은 레이어였습니다. L3는 간접적으로 연결되어있는 두 개의 기기간 통신을 정의해놓은 레이어였습니다. 간접적이라는 건 다른 노드들을 통해서 갈 수 있는 길이 만들어져 있다는 의미구요. 그렇기 때문에 L3부터는 이 데이터를 어디로 보내야 되는지에 대한 내용이 결정되는 구간입니다. 일단... 이번 글에서 제가 정리를 해보려고 하는 건 L4 레이어 중 TCP, UDP 정도입니다. 사실 TCP IP레이어라고 하면 거의 TCP와 UDP가 유일하죠... 먼저 L3까지 통과한 데이터는 이제 상대 호스트 내..
-
L3에 관한 정리
안녕하세요 대학생 개발자입니다. 오늘은 L3에 대해서 정리를 좀 해보도록 하려고 합니다. L1, L2까지는 직접 연결된 단 두 개의 호스트만을 연결할 수 있는 방법에 대해서 제시를 하고 있었는데요 이제 L3로 오게 되면서 멀리 있는 호스트 즉 경유지를 거쳐서 직접 연결되지 않은 호스트에게 데이터를 전달할 수 있는 프로토콜이 등장하게 됩니다. 바로 IP라는 프로토콜입니다. 물론 OSI의 L3는 IP 다는 100% 맞다는 것은 아니지만 TCP/IP 4 layer에서는 일반적으로 IP이기 때문에 IP라고 말씀드렸고요. 그리고 주로 게임 서버에서는 IP 외에는 건드릴 경우가 없다고 생각해서 IP에 대해서 정리를 해보려고 합니다. 123.211.151.4와 같이 IP는 Dotted decimal type으로.으로..
-
L2에 대한 내용 정리
안녕하세요 대학생 개발자입니다. 어제 글을 3개 적으면서 제가 다시 읽어봤는데 주저리주저리에 뇌피셜 가득인 글이더라구요... 어느 정도는 걸러서 들으시면 될 것 같습니다. 부족한 점 있다면 댓글로 잘못된 부분 말씀해 주신다면 반영해서 수정하도록 하겠습니다. 이번 글은 저번에 다 정리해보려고 했던 L7 to L7을 쪼개서 L2부분에 대한 내용만 좀 정리를 해보려고 합니다. 먼저 L2라고 한다면 ethernet을 통해서 전달되는 계층입니다. 즉 L1을 통해서 직접 연결되어있는 기기간의 통신을 정의하는 것입니다. 우선 L2는 연결된 모든 기기에게 데이터를 뿌린다 라는 개념이 존재합니다 브로드캐스팅이라고 합니다 그리고 내가 보내려고 하는 하나의 호스트에게만 데이터를 전달하는 유니캐스트가 존재합니다. 그리고 일부..
-
내 손을 떠난 메시지 처리과정에 대한 정리
안녕하세요 대학생 개발자입니다. 이번 글에서는 TCP IP에 대한 간단한 정리..라고 적어놓고 나열을 해보겠습니다. 이번 글에서 주로 다루게 되는 내용은 다음과 같습니다. L7에서 메시지를 만들어서 다른 L7에게 전달을 하려고 한다면 어떤 일이 일이 일어나는지 간단하게 정리할겁니다. 그럼 시작하겠습니다. L7에서 AAA라는 데이터를 보내려고 한다면 우리는 API를 통해 전달을 해야 할 겁니다. 리눅스의 경우에는 오픈소스이기 때문에 커널이 오픈되어있고 커널에서 직접 뭔가를 할 수 있을것 같지만, 윈도우즈의 경우에는 유저에 대해서 커널이 닫혀있는 os입니다. 그러므로 우리가 직접 하드웨어를 제어하거나 커널에 직접 접근한다는 것은 불가능합니다. 그러므로 우리는 윈도우즈에서 제공하는 API를 사용해서 간접 접근..
-
네트워크의 기본(TCP IP Layer (feat OSI 7Layer))
안녕하세요 대학생 개발자입니다. 이번 글에서는 기본적인 틀이라고 볼 수 있는 OSI 7Layer와 현재 가장 많이 사용하고있는 TCP/IP에 대해서 정리를 해보려고 합니다. 위 그림중 좌측에 보시는 게 osi 7 layer입니다. 하지만 저는 osi 7 layer는 완벽히는 모르고 tcp ip에 빙자해서 대략 설명하려고 합니다! 윗 계층부터 아랫 계층까지 출발해 보겠습니다. Physical layer 진짜 케이블을 의미합니다. 케이블이나 리피터 등 같은 그런 것들입니다. 데이터를 전기신호, 빛 신호 등을 이용해서 전달해주는 애들입니다. 리피터는 생겨먹은 것은 장비처럼 생겨서 L1스위치냐라고 물을 수도 있지만 주소가 존재하지 않을 뿐더러 네트워크 통신에서 그 어떠한 헤더를 뜯어볼 수도 없기 때문에 스위치라..
win socket api 기본 다루기
-
IOCP 사용중 주의사항
안녕하세요 대학생 개발자입니다. 최근 들어서 거의 2일에 한 번꼴로 글들을 찍어내고 있습니다. 거의 이론위주로 작성을 하고 있는데... 사실 내용이 그렇게 쉬운내용은 아닙니다. 당연히 서버개발을 한다면 이 정도 지식은 함양해야 된다고 생각하지만, 이번 글에서는 잠깐 쉬어가는 느낌으로 IOCP를 사용하면서 주의할 사항이나 문제가 생겼을 때 어떻게 대처할지에 대한 논의를 해보려고 해요. 우선 지난 글에서는 IOCP자체에 대한 내용보다는 Overlapped IO의 시각으로써 IOCP를 사용할 때 주의점을 정리했었습니다. 비동기 IO에 대한 문제점들과 이를 해결하기 위한 방법, 그리고 비동기 IO가 무엇인지에 대한 논의도 했었습니다. 이번 글에서는 IOCP로 에코 서버를 만드는 데 있어서 주의해야 할 점에 대해..
-
IOCP + Overlapped IO는 비동기IO인가
안녕하세요 대학생 개발자입니다. 저번 글에서는 IOCP에 대한 내용을 정리했습니다. 글에서 핵심 내용만 몇개 뽑아본다면 다음과 같을겁니다. Overlapped IO Model2에서 IO를 타스레드로 전달하기 위한 조건을 걸다보면 결국 IOCP와 거의 흡사한 모습이된다. IOCP를 효율적으로 사용하기 위해 스레드풀을 사용할것이고 스레드풀은 컨텍스트 스위칭과 캐시히트 때문에 스택형태로 되어져있다. CreateIoCompletionPort함수에 파일 핸들과함께 하나의 키값을 등록할 수 있고 그 키는 GQCS함수를 호출할 때 다시 얻을 수 있다.(일반적으로 세션포인터를 전달하고 세션을 달고다니는 셈이된다) Running Thread와 Worker Thread는 우리가 원하는 만큼 세팅할 수 있으며 WorkerT..
-
IO Completion Port Introduction
안녕하세요 대학생 개발자입니다. 저번 글에서는 Overlapped IO Model2라고 불리는 CALLBACK 방식으로 완료를 통지하는 오버랩 모델에 대해서 논의를 해봤습니다. 이번 글에서는 IOCP에 대한 내용을 다뤄볼 건데요. IOCP는 직전의 글과 같이 동일한 오버랩 모델 중 하나입니다. 먼저 큰 틀에서 말씀을 드린다면 완료 통지를 받는 방법으로 하나의 큐를 통해서 완료 통지를 받고 그 완료 통지를 받았다면 하나의 스레드를 깨워서 작업을 하는 방식을 의미하고 있습니다. 우선 그럼 Overlapped IO Model2에서 IO의 통지를 APC큐를 통해서 했을 경우 문제가 되는 부분은 다음과 같이 말씀드렸습니다. 하나의 APC큐와 IO는 스레드에 종속적이기 때문에 하나의 스레드는 박터져라 일을 하고 있..
-
Overlapped IO Model2
안녕하세요 대학생 개발자입니다. 저번 글에서는 Overlapped IO Model1에 대한 내용에 대해서 언급했었습니다. Overlapped IO Model1에서는 Event를 이용해서 IO에 대한 완료통지를 하는것이라고 했었고, 그렇기 때문에 생기는 비효율적인 면에 대해서 언급했었습니다. 이번글에서 다룰 내용은 Overlapped IO Model2번째 모델입니다. 아마 이전글에서 언급을 했었겠지만 Overlapped IO Model2의 경우에는 Completion_Routine이라는 CALLBACK 등록을 통해서 IO의 완료 통지를 받는다고 했었습니다. 그럼 우선 우리가 알아야 하는건 CALLBACK이 과연 뭐냐입니다. CALLBACK 많은 사람들이 말을하고 있지만 이게 정확히 뭐냐 라고 물어봤을 때 ..
-
Overlapped IO Model + heap
안녕하세요 대학생 개발자입니다. 마지막 글에서 동기화에 대한 얘기와 overlapped io모델에 필요한 구조체들에 대한 간단한 언급을 했었습니다. 이번 글에서는 진짜 overlapped io모델에 대한 얘기를 하려고 합니다. 아 그리고 그 이전에 동적 할당과 힙에 대한 잠깐의 논의를 해보고 넘어가려고 합니다. int * ptr = new int[100]; for(int i=0; i< 140; i++) { ptr[i] = 10; } delete ptr; 다음과 같은 코드가 있습니다. 여기서 에러가 나오는 부분은 어디인가라고 물었을 때 대부분의 입문자분들은 ptr[i] = 10; 부분이라고 말할 겁니다. 이렇게 말씀하시는 이유는 알겠으나 일단은 에러가 어디서나냐는 질문에는 틀린 겁니다. Visual Stu..
-
Overlapped IO Introduction
안녕하세요 대학생개발자입니다. 마지막 글에서 기본적인 소켓 api를 다뤘었습니다. 그리고 한동안 알고리즘과 스레드, 그리고 select 서버에 대한 얘기를 했었습니다. 아마 제가 만든 AsyncSelect 클라이언트를 보셨는지는 모르겠습니다만, 그 이상의 새로운 모델이 아직 나오지 않았었습니다. 그리고 이제 Overlapped IO모델을 정리하면서 동시에 IOCP서버 개발에 착수할 예정입니다. 물론 처음부터 크고 멋진 서버를 만들겠다는 계획은 없습니다. 그리고 스레드 디자인부분도 아직 완벽하지 않기 때문에 확실하게 모든게 짚어지고 나면 그다음 제작에 진입을 할 예정입니다. 우선 서론이 길었습니다. 먼저 이전에 다뤘었던 모델들의 장점과 단점에대한 정리를 간단히 해보고 넘어가도록 하겠습니다. 우선 selec..
-
L4와 L7그리고 서버
안녕하세요 대학생 개발자입니다. 오늘은 주제가 다양하고 내용이 상당부분 겹치는 부분이있습니다... 내용이 많이 겹칠수도 있으니 이미 이전에 보셨던 분이라면 그 부분은 스킵을 하고 넘어 가셔도 좋을듯 싶습니다. 그럼 시작하겠습니다. 우선 마지막으로 올렸던 글에서는 winsocket api의 가장 기본이 되는 echo server에 나오는 비동기 send recv에 대해서 정리를 해봤습니다. 오늘은 살짝 주제를 바꿔보려고 합니다. 먼저 L2에는 ARP RARP등의 프로토콜이 존재합니다. L3에는 IP, ICMP등의 프로토콜이 존재합니다. L4에는 TCP, UDP등의 프로토콜이 존재합니다. 그들은 각각 자신의 프로토콜과 그에 맞는 syntax와 semantics를 가지고있습니다. 그것들을 가지고 통신을 정의하..
-
Win socket API2
안녕하세요 대학생 개발자 입니다. 오늘도 역시 winsocket api에 대해서 정리를 해볼까 하는데요... 마지막으로 남겼을때가 listen, accept, bind, socket함수 정도 했었는데요 오늘은... 일단 에코서버의 남은 부분인 recv, send에 대해서 정리를 해볼까 합니다. recv에 대해서 먼저 설명을 해볼까 합니다... 일단 먼저 recv라고 하면 recieve의 줄인말이겠죠 . 받다. 도대체 받는다는게 무엇을 의미하는지 궁금합니다. 우리는 recv를 호출해야지 과연 상대방이 보낸 데이터를 우리의 TCP가 받아들이는 걸까요? 음... 우선 L7과 그 밑을 얘기를 해야겠는데요 먼저 TCP와 소켓은 커널입니다. 커널이라고 하면 우리가 접근할 수 없는 부분인데요... 왜 접근을 못하게 ..
-
Window Socket API 기본 정리1
안녕하십니까 여러분 대학생 개발자입니다. OSI레이어부터 시작해서 L2 L3 L4까지 차근차근 하나씩 단계를 밟아가면서 정리했습니다. 이제 L5 ~ L7이라고 불릴 수 있는 어플리케이션 레이어에서의 네트워크를 정리하려고 합니다. msdn을 조금씩 참고해서 적긴하는데... msdn에 있는 문서나 사진을 올리진 않습니다... 제 머릿속에 있는 내용을 최대한 끄집어 내려고 하기 때문이니까... 이해 부탁드립니다. 음... 순서도 그렇고 내용도 그렇고 뒤죽박죽일겁니다... 하지만 이 블로깅에 목적은 역시 제가 나중에 다시 보고 공부하기 위해서 남기는 목적이다보니... 이런 배려는 없다는점 유의하시길 바랍니다 ㅋㅋㅋㅋㅋ 추가로 여기에 올라오는것중 많은 부분이 생략이 되어있을 겁니다. 그건... 다른 블로그나 다른..
-
Windows 에서 listen함수의 Backlog Queue의 크기를 구해보자.
안녕하세요 대학생 개발자입니다. 오늘의 목표는 listen을 했을 때 커널에 back log queue(listen queue)가 생기는데 그 큐의 사이즈의 크기를 코드로 직접 구해보려고 합니다. 서버 측에서 listen을 콜 할 때 SOMAXCONN -> 7fffffff signed int 중 가장 큰 값을 인자로 전달합니다. client에서 실제 connect를 과연 몇 개까지 할 수 있을까를 실험해봤습니다. client는 무한루프를 돌면서 loop back address:8000 으로 connect를 시도합니다. 실제 연결된 클라이언트 수는 200명에 불과합니다. 분명 나는 signed int 중 가장 큰 값인 7fffffff를 인자로 전달했는데 왜 200개밖에 되지 않을까? 당연히 21억어쩌고하는..
c, c++ basic
-
c_4
안녕하세요 대학생개발자입니다. 이번글에서는 반복문에 대해서 간단히 알아보겠습니다. 반복문이란 말 그대로 코드가 반복되는 구간을 의미하는거겠죠... 그리고 거의 모든 반복에는 조건이 있습니다. 우선 반복문에 어떤것들이 있는지부터 봐야할 것 같습니다. 첫번째로 for문이 있습니다. 두번째로 while문이 있습니다. 세번째로 do while문이 있습니다. 먼저 조건문에 공통적으로 들어가는 구성에 대한 얘기를 먼저 해보겠습니다. 1. 초기식 2. 조건식 3. 증감식 조건식에는 위의 세가지 구성이 들어가는데요. 초기식의 경우에는 말그대로 조건식에서 사용될 값을 초기화 해주는 부분입니다. 초기화되지 않은 값을 사용하게되면 visual studio에서는 컴파일 에러를 뱉어주지만 그외 다른 컴파일러에서는 에러를 뱉어주..
-
c_3
안녕하세요 대학생 개발자입니다. 이번 글에서는 이제 모든 코드에 로직이라는것을 결정하는 조건문이나 반복문에 대해서 알아볼거에요. 우선 조건문이라는게 무엇일까요? 말 그대로 어떤 조건에서 실행하고 어떤 조건이 아니면 실행하지 않겠다는 의미로 해석이 되는데요. 우선 조건문은 크게 두가지로 쓰이는데요 첫번째는 if문이고 두번째는 switch문입니다. if문의 경우에는 true와 false로 떨어지는 하나의 명제를 넣어서 그 명제가 참이라면 실행하고 참이 아니라면 실행하지 않는 구문이에요. 물론 if문이라고 해서 꼭 if만 있는건 아닙니다. if 조건에 해당하지 않는 경우에만 실행하고 싶은 부분이 분명 있기 때문에 else라는 키워드도 같이 제공하고 있습니다. if(조건){ 실행블럭 } else{ 실행블럭 } ..
-
c_2
안녕하세요 대학생개발자입니다. 이번글은 저번글에 이어서 C언어에대한 기본 두번째 글입니다. 사실 C언어라는게 막상 접해보면 그렇게 어렵지 않은데 많은분들이 어려운줄 알고계셔요 그래서 어떻게하면 쉽게 설명할 수 있을까 고민하며 적고있습니다. 이번글에서는 자료형에 대한 얘기와 함께 데이터가 실제 어떻게 저장되는지에 대한 얘기를 좀 해볼겁니다. 자료형은 간단히 말하면 어떤 방식으로 이 데이터를 저장할거냐 혹은 표현할거냐 입니다. 저 방식이라는 것에는 다양한게 존재할수있는데요. 첫번째로 데이터를 크기에 따라 나누는 방법이 있습니다. 두번째로 데이터의 종류에 따라 나누는 방법이 있습니다. 먼저 데이터를 크기에 따라 나누는 방법인데요 여러분이 계산기를 사려고 한다고 생각해봅시다. 난 3자리 이상의 연산을 할일이 없..
-
c_1
안녕하세요 대학생 개발자입니다. 오랜만에 돌아왔습니다. 그리고 진짜 기본이라는 새로운 카테고리를 가지고 돌아왔습니다. 이 카테고리는 c언어를 처음하시는 분들을 위한 카테고리입니다. 만약 나는 이런거 볼 레벨은 아닌데...? 하시는분들과 서버 개발일지를 보러 오셨다면 과감히 좋아요를 누르고 뒤로가기를 눌러주시면 감사하겠습니다. 먼저 변수에 대한 얘기를 해보려고합니다. c언어의 책에 뭐라고 써져있는지 모르겠지만 변수는 사실 정해진 크기의 값을 담을 수 있는 공간입니다. 이렇게 말로만 말씀을 드리면 이해가 안되실겁니다... 지금 제입장에서는 너무나도 당연히 받아들여지는 부분이 입문한지 얼마안되신 분들께는 어려운 내용이니 말이죠. 우선 변수를 선언하는 방법은 다음과 같습니다. 타입 이름 = 값;(int a = ..
-
상속에 대한 얘기
안녕하세요 대학생 개발자입니다. 이번글에서는 상속에 관한 얘기를 좀 해보고 싶습니다. 사실 상속을 얘기하려면 생성자부터 모조리 다시 얘기를 해야됩니다.ㅠㅠ(물론 예전처럼 하지는 않을겁니다) 상속이란건 말그대로 그 객체의 모든 정보를 내가 이어 받는거죠. 그정보를 이어받아서 내가 추가를 하든 아니면 필요없는건 제외를 하든 그렇게 사용하라는겁니다. 뭐... 상속에서 public protected private상속 일때 접근을 어떻게하는가 이런건... 뭐 건너뛰겠습니다 그런걸 논할 글은 아니라고 생각합니다. 우선 상속을 할때 부모의 생성자가 존재한다면 그 밑의 클래스 즉 하위클래스들은 전부다 생성자가 존재해야됩니다. 이유는 당연하죠 하위 클래스의 생성자에서 상위클래스의 생성자를 호출해야되기 때문이죠. 그리고 ..
-
class에 대한 얘기(2)
안녕하세요 대학생 개발자입니다. 이번글에서는 저번글에 이어서 클래스에 대한 정리를 좀더 해보려고합니다. 저번글에서는 기본 생성자와 소멸자에 대한 얘기를 해봤습니다. 그럼 다음으로 기본 복사생성자에 대한 얘기를 해보겠습니다. 우리가 코딩을할때 분명 복사생성자를 만든 기억이 없음에도 이런 복사생성자 호출이 가능해집니다. 그렇다는 말은 컴파일러가 복사생성자를 만들어 준다는 의미겠죠. 네. 여기까지가 c++을 훌륭히 배워오신 분들이 가지고 있는 지식입니다. 하지만 조금만 더 깊게 들어가보겠습니다. 어셈블리를 통해서 기본 복사생성자라는 것을 자세히 보면 그냥 memcpy호출과 동일합니다. 네... 이게 기본 복사생성자의 실체입니다. 그냥 복사를 드르르르륵 하고 있는 상황인겁니다. 아... 그럼 memcpy를 한번..
-
template와 class에 대한 얘기(1)
안녕하세요 대학생 개발자입니다. 이번글에서는 template에 대해서 정리를 해보려고합니다. 우선 템플릿에 대해서 얘기하기 전에 우리가 c언어에서 부터 지금까지 모든 타입이라는 개념을 어떻게 해왔는지를 간단히 정리해보도록하겠습니다. 똑같은 기능을 변수 타입만 바꼈을때 똑같이 쓰는방법... c언어에서는 당연 다른 함수를 만들어야됬습니다. int add(int a, int b); float add(float a, float b); 이런 오버로딩의 개념은 c언어에서는 지원하지 않으니까요... c언어에서는 안타깝게도 이런방식을 써왔었습니다. int addInt(int a, int b); float addFloat(float a, float b); 그리고 c++에서는 이를 조금 보안해서 오버로딩이라는 개념을 지원..
-
new와 delete에 대한 얘기
안녕하세요 대학생 개발자입니다. 이번에 다뤄볼 내용은 동적할당에 대한 얘기입니다. 할당에는 두가지 방법이 있을겁니다. 정적할당과 동적할당 이렇게 말이죠. 일반적으로 우리가 처음 C++을 배울때 main함수를 사용하게 될텐데요. 메인함수와 같은 함수 즉 지역내에 선언되는 변수들은 모두 정적할당을 통해서 얻어지는 메모리입니다. 컴파일러가 컴파일 타임에 어느정도를 할당해야될지 정해서 올려버리는 값들이죠. 마찬가지로 전역변수도 같습니다. 컴파일타임에 존재하는 변수이기 때문에 정적으로 공간이 할당되어 버리죠... 하지만 분명히 우리가 예상하지 않았던 크기의 공간이 필요하게 될 수도있습니다. 물론 스택으로 일부 커버를 할 수 있긴 합니다. 하지만... 100바이트면 충분할줄 알았던 것이 1000바이트가 되면요..?..
-
메모리와 c++에 관한 얘기
안녕하세요 대학생개발자입니다. 이번 글에서는 메모리에 대한 얘기를 하려고합니다. 아참 예전에 메모리가 있지않았나요? 라고 생각하실 분들을 위해서 말씀드리지만 이 메모리는 예전의 메모리에 비해 많이 심도가 깊어졌습니다... 그럼 우선 시작하겠습니다. 우선 저번 글에서 좀 적었으면 싶었는데 너무 피곤한 탓에... 빨리 정리를 해서 못 정리한 내용에 대해서 간략하게 정리를 좀 하고 넘어가도록 하겠습니다. 저번 글에서는 file io에대해서 얘기를 해봤는데요 그럼 결국 다른 프로세스에 접근하는것도 file io이지 않겠는가 입니다. 다른 프로세스의 메모리에 접근하는것과 파일에 접근하는것 두개가 다른게 전혀없다는거죠 결국 메모리에 올려서 값을 쓰고 그걸 다시 돌려놓고를 할거기 때문이죠.. windows에서는 Wr..
-
DLL,LIB, FILEIO에 대한얘기
안녕하세요 대학생개발자입니다. 이번 내용에서는 dll과 lib에 대한 차이점을 아주 간단하게 정리하고 FILE IO에 대해서 얘기를 좀 해보려고합니다. 음... 우선 우리가 dll이나 lib를 쓰는 이유가 뭘까에 대한 고민을 우선 해봐야겠는데요... 당연히 dll과 lib가 없으면 무조건적으로 안된다는 아닙니다. 왜냐면 소스를 그대로 주는 것과 dll, lib를 주는것과는 다를바가 없거든요... 어차피 내가 주려고 하는 라이브러리를 준다는 부분에서는 동일한거니까요 하지만 source code의 경우에는 역시... 고대로 전달하게 되면 내 모든것을 공개하는것과 동일합니다... 남이 내가 어떻게 코드를 짰는지 노출의 위험이 있는 것부터 시작해서 내가 만들어놓은 코드를 변경할 여지도 있고 이런 위험이 있습니다..
-
게임서버 이론1
안녕하세요 대학생개발자입니다. 이번 글에서는 여러가지가 짬뽕이 될 것같은데요... 사실 이걸 c,c++로 넣어야될지 아니면 게임서버쪽으로 봐야될지 고민을 하다가 그냥... 이것만을 위해서 새로운 카테고리를 파기는 좀 그래서 그냥 c,c++로 넣어버렸습니다. 일단 시작하겠습니다. 음... 어떻게 시작해야될지를 모르겠습니다. 사실 이부분을 필기한지가 꽤나 시간이 지나서 무슨 말을 했었던건지도 기억이안나고... 필기도 너무 빠르게 해서 그런지 핵심내용이 많이 사라져있네요... 일단 서버의 경우에는... 대체적으로 하드웨어를 분산시키는 기법을 많이 사용하죠. 말그대로 분산서버인데요. 아마 구글링을 해보신 분들은 다 아시겠지만 뭐 채팅서버, 로그인서버, 로비서버, 게임서버, 월드서버, NPC서버 등등 다양한 서버..
-
시간과 랜덤에 관한 얘기
안녕하세요 대학생 개발자입니다. 이번에는 시간과 랜덤에 대해서 정리를 좀 해보려고합니다. 음 무슨 이름이 드래곤볼에 나올거같은 방이름인데요... 우선 우리가 아는 시간 컴퓨터는 어떻게 알고있을까요? 사실 시간이라는 개념은 컴퓨터는 알수가 없죠 왜냐면 사람이 기준을 정했으니까요... 우선 1초라는게 뭔지 알아봐야 될 것 같은데요 실제 1초의 기준입니다. "초는 세슘-133 원자의 바닥상태에 있는 두 초미세 준위간의 전이에 대응하는 복사선(방사)의 9,192,631,770 주기의 지속시간이다." 그럼 컴퓨터가 진짜 1초를 세기위해서 세슘-133원자의 바닥상태에 있는 어쩌고 저행동을 할까요?? 그럴리가없죠... 절대로... 컴퓨터가 시간을 재는 방법은 cpu가 한번 진동하는 틱이라고하죠? 클럭이요.. 그래서 ..
-
문자열과 해시에 대한 얘기
안녕하세요 대학생 개발자입니다. 이번 글에서는 표준 c에서 제공하는 문자열과 위험한 부분 그리고 우리는 어떻게 써야되는지에 대한 내용과 해시에 대한 내용을 간단하게 정리하고 넘어가고자 합니다. 우선 windows의 visual studio환 경에서 문자열을 쓰다보면 scanf함수가 작동이 안되는 경우를 확인할 수 있습니다. 이렇게 말이죠... 이건 사실 다른 컴파일러에서는 에러사항은 아닙니다. 하지만 windows의 vs가 특별히 안전한 버전인 _s를 붙인 버전을 제공하고 있기 때문인데요... 사실... 문자열의 비교를 위한 strcmp, 그리고 문자열의 길이를 알아내는 strlen과 같은 함수들은 _s 버전이 존재하지 않습니다 그이유는 뭘까요? 우선... _s가 존재하는 기준에 대해서 알아봐야되겠는데요..
-
메모리에 대한 얘기
안녕하세요 대학생개발자입니다. 그럼 계속 이어서 하도록하겠습니다. 저번 글에서는 alignas키워드에 대한 내용을 좀 다뤘는데요. 이번 내용에서는 메모리에 대해서 좀 알아보려고합니다. 우선 메모리에 대해 하기전에 추가로 내용을 더 정리하고 가면요 heap의 경우에는 alignas키워드를 사용해도 맞지 않습니다(malloc의 경우에는 안맞습니다). 하지만 _aligned_malloc() 이라는 함수를 제공하고 2번째 인자로 어디에 맞출것인지에 대한 인자를 받습니다. 그럼 _aligned_malloc은 어떻게 만드는걸까요? 내가 내가 어떤 구조체가 필요한데 이걸 64바이트에 맞춰버리고싶습니다. 그럼 실제로 할당하는 양은 64바이트에 + 64이하 바이트들을 전부다 1로 세팅한 값을 더해버립니다. 즉 63을 더..
-
바이트 패딩과 캐시에 대한 얘기
안녕하세요 대학생 개발자입니다 오늘은 바이트 패딩이 왜 그 타입의 사이즈의 경계에 맞게 나오게 되는지 이유를 좀 알아보려고합니다. 네 먼저 저번 내용을 간단히 요약해본다면 어떠한 구조체가 있을때 char의 경우에는 1바이트의 경계에 세우면 반으로 잘리지 않기 때문에 사실상 어디에 있어도 상관이 없습니다. short, int, double등과 같이 1바이트가 아닌 변수들은 각자의 사이즈의 경계에 서야 된다는것도 알았습니다. 그리고 구조체 자체의 패딩또한 가장 큰 변수에 맞춰서 패딩이 된다는 것도 알았습니다. 그럼 여기서 한단계만 더 들어가보겠습니다 왜 이렇게 맞춰야하는가입니다. 이유는 단순한데요 캐시라인이 64바이트이기 때문입니다. 물론 어느 아키텍쳐냐에 따라 달라지겠지만 요새 cpu들은 대부분 64byt..
-
전처리기, 바이트패딩룰에대한 얘기
안녕하세요 대학생개발자입니다. 저번글에서는 함수에 대한 내용을 다뤄봤습니다. C언어의 내용을 순서대로 나열해보자면 이쯤에서 포인터를 다루는게 일반적이겠으나... 포인터변수에 대한 내용은 지금 다룰 내용은 아니고 그보다 더 원초적이고 기본이 될 만한 지식을 다지는 것이 더 중요합니다. 그럼 시작하도록 하겠습니다. 우선 전처리기에 대한 내용이 아주아주아주 살짝 나오게 될것입니다. 그리고 typedef와 const와도 좀 비교가 될 것이구요. 우선 우리가 자주 쓰는 전처리기 명령어 #include 와같은 이런 #이 붙은 명령어들이 전처리기 명령어인데요. 저도 사실 전처리기에 대해서는 잘 모르기 때문에 간단하게 정리하려고 합니다. 우선 말 그대로 전 처리기죠 컴파일 이전에 정해진 명령어들을 수행하는 녀석입니다...
-
함수에 대한 얘기
안녕하세요 대학생 개발자입니다. 이어서 C언어 기본에 대해서 얘기를 하려고 합니다. 점프 테이블을 끝으로 마무리를 했던 것 같은데요... 아쉽게도 오늘도 점프 테이블이 등장할 겁니다. 하지만 이번에는 스위치에 대한 점프 테이블은 아니고요. 함수에 대한 점프 테이블인데요. 물론 이 점프 테이블의 경우에는 디버그 빌드에서만 나오는 거긴 하지만... 링킹 타임을 획기적으로 줄이는 방법이기 때문에 이렇게 했답니다. 그럼 우리는 call Foo라는 코드를 전부 점프 테이블로 가게 만들고 점프 테이블의 값만 수정해주면 끝나기 때문이죠. 네 뭐... 점프 테이블은 이런 식으로 생겨먹었습니다. 이상한 다른 함수들이 많은데 제가 따로 뭐 하고 있는 데다가 그냥 점프 테이블 보려고 잠시 디버그로 바꾼 거라서 저런 겁니다...
-
연산자와 조건문에 대한 얘기
안녕하세요 대학생 개발자입니다. 이번 글에서는 연산자와 조건문에 대한 얘기를 간단히 해보려고합니다. ----- cpu는 1,0 으로만 읽을 수 있는데 음수와 뺄셈을 어떻게 하는지..? 우선 이전 글에서 변수에 대한 언급을 했었습니다. 변수는 공간일 뿐이라고 말씀드렸었던 부분이 있는데요. 그저 공간밖에 존재하지 않는 상황에서 연산은 어떻게하며 뺄샘과 같은 처리는 어떻게 하는지 의문이실겁니다. 시작 전에 말씀드리지만 메모리에는 음수라는 개념이 존재하지 않습니다. 그저 1,0 만 존재하는 공간에 불과합니다. 이를 음수라고 정의하는건 사람이 한것이죠. 우선 시작하겠습니다. + 연산은 2진수에서도 10진수와 동일합니다 1111 + 1 = 10000 이죠 1010 + 101 = 1111 이죠 하지만 뺄샘같은 경우는..
-
변수와 타입, 키워드에관한 얘기
안녕하세요 대학생 개발자입니다. 이번 글에서는 c언어의 기본을 공부할 때 간략하게 듣긴 했지만 정확한 원리에 대한 생각을 해보지 않았을 부분에 대해서 언급을 하려고 합니다. 게임 서버를 개발하실 정도의 실력이 가지고 계신 분들이라면 다 아실법한 내용들이 위주로 나오게 됩니다. 그러니까 아시는 분들은 어느 정도 걸러서 들으셔도 좋습니다. 게임서버를 개발하며 가장 중요한건 최적화와 안정성입니다. 알고리즘에 대한 최적화 부분도 상당부분 중요합니다. 하지만 당연히도 알고리즘만으로 최적화 할 수 있는 부분은 한계가 있습니다. 우선 우리는 메모리라는 녀석이 어떻게 생겨먹은 녀석이고 어떻게 사용할때 효율적인지를 알아보기 위해서 메모리에 대해 알아보고 갈겁니다. 그러다 보니 자연스럽게 언어와 관계없이 메모리 관점에서의..
C,C++_진짜기본
-
c_4
안녕하세요 대학생개발자입니다. 이번글에서는 반복문에 대해서 간단히 알아보겠습니다. 반복문이란 말 그대로 코드가 반복되는 구간을 의미하는거겠죠... 그리고 거의 모든 반복에는 조건이 있습니다. 우선 반복문에 어떤것들이 있는지부터 봐야할 것 같습니다. 첫번째로 for문이 있습니다. 두번째로 while문이 있습니다. 세번째로 do while문이 있습니다. 먼저 조건문에 공통적으로 들어가는 구성에 대한 얘기를 먼저 해보겠습니다. 1. 초기식 2. 조건식 3. 증감식 조건식에는 위의 세가지 구성이 들어가는데요. 초기식의 경우에는 말그대로 조건식에서 사용될 값을 초기화 해주는 부분입니다. 초기화되지 않은 값을 사용하게되면 visual studio에서는 컴파일 에러를 뱉어주지만 그외 다른 컴파일러에서는 에러를 뱉어주..
-
c_3
안녕하세요 대학생 개발자입니다. 이번 글에서는 이제 모든 코드에 로직이라는것을 결정하는 조건문이나 반복문에 대해서 알아볼거에요. 우선 조건문이라는게 무엇일까요? 말 그대로 어떤 조건에서 실행하고 어떤 조건이 아니면 실행하지 않겠다는 의미로 해석이 되는데요. 우선 조건문은 크게 두가지로 쓰이는데요 첫번째는 if문이고 두번째는 switch문입니다. if문의 경우에는 true와 false로 떨어지는 하나의 명제를 넣어서 그 명제가 참이라면 실행하고 참이 아니라면 실행하지 않는 구문이에요. 물론 if문이라고 해서 꼭 if만 있는건 아닙니다. if 조건에 해당하지 않는 경우에만 실행하고 싶은 부분이 분명 있기 때문에 else라는 키워드도 같이 제공하고 있습니다. if(조건){ 실행블럭 } else{ 실행블럭 } ..
-
c_2
안녕하세요 대학생개발자입니다. 이번글은 저번글에 이어서 C언어에대한 기본 두번째 글입니다. 사실 C언어라는게 막상 접해보면 그렇게 어렵지 않은데 많은분들이 어려운줄 알고계셔요 그래서 어떻게하면 쉽게 설명할 수 있을까 고민하며 적고있습니다. 이번글에서는 자료형에 대한 얘기와 함께 데이터가 실제 어떻게 저장되는지에 대한 얘기를 좀 해볼겁니다. 자료형은 간단히 말하면 어떤 방식으로 이 데이터를 저장할거냐 혹은 표현할거냐 입니다. 저 방식이라는 것에는 다양한게 존재할수있는데요. 첫번째로 데이터를 크기에 따라 나누는 방법이 있습니다. 두번째로 데이터의 종류에 따라 나누는 방법이 있습니다. 먼저 데이터를 크기에 따라 나누는 방법인데요 여러분이 계산기를 사려고 한다고 생각해봅시다. 난 3자리 이상의 연산을 할일이 없..
-
c_1
안녕하세요 대학생 개발자입니다. 오랜만에 돌아왔습니다. 그리고 진짜 기본이라는 새로운 카테고리를 가지고 돌아왔습니다. 이 카테고리는 c언어를 처음하시는 분들을 위한 카테고리입니다. 만약 나는 이런거 볼 레벨은 아닌데...? 하시는분들과 서버 개발일지를 보러 오셨다면 과감히 좋아요를 누르고 뒤로가기를 눌러주시면 감사하겠습니다. 먼저 변수에 대한 얘기를 해보려고합니다. c언어의 책에 뭐라고 써져있는지 모르겠지만 변수는 사실 정해진 크기의 값을 담을 수 있는 공간입니다. 이렇게 말로만 말씀을 드리면 이해가 안되실겁니다... 지금 제입장에서는 너무나도 당연히 받아들여지는 부분이 입문한지 얼마안되신 분들께는 어려운 내용이니 말이죠. 우선 변수를 선언하는 방법은 다음과 같습니다. 타입 이름 = 값;(int a = ..