---> 실습 1일차 <---
* 생성
File -> New -> Project ->Win32 Console App.. -> Simple ...
* 설정
File View 창 -> Header Files -> stdAfx.h 편집
#include
* ws2_32.lib 라이브러리 추가
1) Project -> Setting -> Link -> Object/libraly modules
뒤에 ws2_32.lib 열을 추가
2) #pragma comment (lib, "ws2_32.lib") 열을 헤더파일에 추가
실습 내용
#include "stdafx.h"#include
int main(int argc, char* argv[]){
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(2,2);
if(WSAStartup(wVersionRequested, &wsaData) != 0) {
return FALSE;
}
if(LOBYTE(wsaData.wVersion) != 2 HIBYTE(wsaData.wVersion) != 2) {
WSACleanup();
return FALSE;
}
printf("WSAStartup success...\n");
return 0;
}
* Endian
0x12, 0x34, 0x56, 0x78
^ ^ ^ ^
l l
MSB LSB
-------------------
ADDR 10 20 30 40
-------------------
Big Endian 12 34 56 78
--------------------
Little Endian 78 56 34 12
--------------------
2 X 2
(1) H = > N (1) long
(2) N = > H (2) short
위의 조합으로 만든다...
예) htonl( host to network long) -> 호스트에서 네트워크로 크기는 long 타입으로...
댓글 없음:
댓글 쓰기