소켓 초기화 시키기

보통 WSAStartup -> socket -> closesocket -> WSACleanup 순으로 이뤄진다.

서버 WSAStartup -> socket -> bind -> listen ->  accept -> closesocket -> WSACleanup

클라 WSAStartup -> socket -> connect -> closesocket -> WSACleanup


WSADATA wsaData;

SOCKET sock;

SOCKADDR_IN addr;


WSAStartup( MAKEWORD( 2, 2 ), &wsaData );

sock = socket( AF_INET, SOCK_STREAM, 0 );


memset( ( void * )&addr, 0, sizeof( SOCKADDR_IN ) );

addr.sin_family = AF_INET;

addr.sin_addr.s_addr = inet_addr( IP_ADDRESS );

addr.sin_port = htons( PORT_NUMBER );


closesocket( sock );

WSACleanup();

'NativeCode > api' 카테고리의 다른 글

Client Socket  (0) 2010.03.19
① WSAStartup  (0) 2010.03.19
C++ Style Socket  (0) 2010.03.19
Client Source  (0) 2010.03.19
Server Source  (0) 2010.03.19

+ Recent posts