MSDN Network 관련 함수들

from Study/Network 2007/11/27 22:34 view 36131

1.1 Transformation Functions

htonl
htons
inet_addr
inet_ntoa
ntohl
ntohs

1.2 DataBase Functions

gethostbyaddr
gethostbyname
gethostname
getprotobyname
getprotobynumber
getservbyname
getservbyport

1.3 Socket Functions

accept
bind
closesocket
connect
getpeername
getsockname
getsockopt
ioctlsocket
listen
recv
recvfrom
select
send
sendto
setsockopt
shutdown
socket


2. Windows  Socket  Extension  APIs

2.1 Transformation Functions

WSAHtonl
WSANtohl
WSAHtons
WSANtohs

2.2 DataBase Functions

WSAAsyncGetHostByAddr
WSAAsyncGetHostByName
WSAAsyncGetProtoByName
WSAAsyncGetProtoByNumber
WSAAsyncGetServByName
WSAAsyncGetServByPort
WSAEnumProtocols

2.3 Socket Functions

WSAAsyncSelect
WSACancelAsyncRequest
WSACancelBlockingCall
WSACleanup
WSAGetLastError
WSAIsBlocking
WSASetBlockingHook
WSASetLastError
WSAStartup
WSAUnhookBlockingHook
WSAEventSelect
WSAAccept
WSASend
WSASendTo
WSARecv
WSARecvFrom
WSAConnect
WSAloctl
WSAJoinLeaf
WSARecvEx
WSASocket
WSAWaitForMultipleEvents
WSAEnumNetworkEvents
WSACreateEvent
WSAGetOverlappedResult
WSASetEvent
WSAResetEvent


3. Socket  Structures

SOCKADDR
SOCKADDR_IN
IN_ADDR
HOSTENT
PROTOENT
SERVENT
LINGER
FD_SET
TIMEVAL
WSADATA
WSABUF
WSAOVERLAPPED
WSAPROTOCOL_INFO
WSANETWORKEVENTS

Tag |

익스플로러의 힘은 막강하다.

무려 보기->인코딩 에서 선택되는 방식에 따라서 시스템 전역으로 영향을 끼친다. 어설프게 설정했다가는

한글의 깨진 글씨만을 보게 된다. 아 윈도우~ -_-...

이 문제를 전에 어느 블로그에서 VS 2005에서 한글로된 프로젝트를 실행하지 못하는 문제를 해결하는 법을 보지

않았다면 개고생, 뻘짓을 할 뻔 했다.. 기억은 안나지만 그분에게 고마울 따름이다.

한글이 깨지거나 열리지 않거나 등등이 상황이 발생되면 무조건~ 익스플로러의 보기->인코딩 먼저 보자..ㅠ_ㅠ...

Tag |
1. msdn 참고
http://msdn2.microsoft.com/en-us/library/eeah46xd(VS.80).aspx


2. MFC의 Message Reflection 을 활용해서만든다.
In MFC 4.0, the old mechanism still works ? parent windows can handle notification messages. In addition, however, MFC 4.0 facilitates reuse by providing a feature called "message reflection" that allows these notification messages to be handled in either the child control window or the parent window, or in both.

3. 서브클리싱, 가상함수의 개념만 있다면 쉽게 이해 할 수 있다. 자식이 부모가 요청한 작업을 한다.
Windows controls frequently send notification messages to their parent windows. For instance, many controls send a control color notification message (WM_CTLCOLOR or one of its variants) to their parent to allow the parent to supply a brush for painting the background of the control.


예제 1. CEdit 클래스로 부터 상속받은 클래스로 에디트 박스의 배경색과 글자색을 정한다.

more..


예제 2. CListBox 로 상속받아은 클래스로 아이콘을 포함하는 리스트박스를 구현.

more..


예제 3. CStatusBar 에 안에 다른 Control을 포함시키기. Control in Control

more..



Tag |

hash 기본 구현.

from Study/자료구조 2007/11/27 19:19 view 31682
해쉬 구조를 알기 위해선 아래 문서를 읽어 보고...c로 해쉬를 구성해보자.
http://lxr.linux.no/source/include/linux/hash.h


1. 해쉬 함수는 여러가지 알고리즘이 있으나 커널에서는 간단하면서도 우수한 folding exclusive 방식을 사용.

#define PIDHASH_SZ  16
#define
pid_hashfn(x)   ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))

pid_hashfn(777)

( ( 777 >> 8 ) ^ 777 ) & ( 16 - 1 )

777                                           => 1100001001
777 >> 8                                   => 0000000011
( 777 >> 8 ) ^ 777                      => 1100001010
16 - 1                                       => 0000001111
( ( 777 >> 8 ) ^ 777 ) & ( 16 - 1 )  => 0000001010

2. 해쉬는 탐색을 위한 자료구조라고도 할 수 있다. 자료를 효율적으로 분산하여 저장할 수 있게 된다.
사용자 삽입 이미지
사용자 삽입 이미지


전체 소스~

more..

List를 C로만 구성하기 위해서 공개된 list 를 참고해 본다.
일단  http://lxr.linux.no/source/include/linux/list.h 를 참조.

1. 보통 리스트를 구현할 때 리스트와 자료형을 같이 사용하지만 이런 구현은 매번 리스트를 따로 구현해야하는 아픔이 있다.
사용자 삽입 이미지


2. 그래서 리스트의 구조를 구조체를 만들때 그 밑에 구현 해 놓는 방식을 사용하도록 한다.
3. 이렇게 되면 리스트를 포함 시켜놓으면 헤더 파일을 중심으로 리스트를 가질수 있다.

사용자 삽입 이미지

4. 리스트의 추가는 앞뒤의 객체에게 알려주면 된다.
void __list_add(struct list_head *new=0x3004,

            struct list_head *prev=0x1000,

            struct list_head *next=0x2004)

{

  next->prev = new;

  new->next = next;

  new->prev = prev;

  prev->next = new;

}


5. 구조체의 내용을 읽기 위해선 시작위치를 0으로 시작한다는 개념을 잡아야 한다. 

#define  list_entry( temp, type, list ) \

((type *)((char*)temp (unsigned long)(&((type *)0)->list)))

TASK *p = list_entry( temp, TASK, list );

p->pid;


전체 소스 ~

more..