JNetLibray
로딩중...
검색중...
일치하는것 없음
WinSocketAPI.h
이 파일의 문서화 페이지로 가기
1#pragma once
2
3#include <WinSock2.h>
4#include <MSWSock.h>
5#include <WS2tcpip.h>
6#pragma comment(lib, "ws2_32")
7
8#include "CommTypes.h"
9
10#ifndef IN
11# define IN /* marks input param */
12#endif
13#ifndef OUT
14# define OUT /* marks output param */
15#endif
16#ifndef INOUT
17# define INOUT /* marks input+output param */
18#endif
19
21// 윈도우 소켓 라이브러리 초기화 (WSAStartUp 호출)
23int InitWindowSocketLib(LPWSADATA);
24
26// SOCKET 객체 생성
27// - isTCP == true, TCP 프로토콜용 소켓 객체 생성(AF_INET, SOCK_STREAM)
28// - isTCP == false, UDP 프로토콜용 소켓 객체 생성(AF_INET, SOCK_DGRAM)
30SOCKET CreateWindowSocket_IPv4(bool isTCP, OUT int* errCode = NULL);
31
32/*********************************************************************************
33* Client
34**********************************************************************************/
36// Connect API 인수로 전달할 서버(도착지) 주소 구조체 생성
38SOCKADDR_IN CreateDestinationADDR(const char* destIP, uint16 destPort);
39SOCKADDR_IN CreateDestinationADDR(IN_ADDR destInAddr, uint16 destPort);
40SOCKADDR_IN CreateDestinationADDR_LoopBack(uint16 destPort);
41SOCKADDR_IN CreateDestinationADDR_byDomain(WCHAR* destDomain, uint16 destPort);
42
43bool ConnectToDestination(const SOCKET& sock, const SOCKADDR_IN& destAddr, OUT int* errCode = NULL);
44
45//int ConnectSocket(SOCKET& sock, SOCKADDR_IN& serverAddr);
46//bool ConnectSocketTry(SOCKET& sock, SOCKADDR_IN& serverAddr);
47
48
49/*********************************************************************************
50* Server
51**********************************************************************************/
52SOCKADDR_IN CreateServerADDR(const char* serverIp, uint16 port);
53SOCKADDR_IN CreateServerADDR_ANY(uint16 port); // INADDR_ANY
54SOCKADDR_IN CreateServerADDR_LoopBack(uint16 port); // LoopBack
55
56bool BindSocket(SOCKET& sock, SOCKADDR_IN& serverAddr, OUT int* errCode = NULL);
57bool ListenSocket(SOCKET& sock, int backlog, OUT int* errCode = NULL);
58
59// if socket returned == INVALID_SOCKET,
60SOCKET AcceptSocket(SOCKET& sock, SOCKADDR_IN& clientAddr, OUT int* errCode = NULL);
61
62
63// INADDR_IN -> std::string IP 주소
64void IN_ADDR_TO_STRING(const IN_ADDR& inAddr, char ipStr[INET_ADDRSTRLEN]);
65
66// 도메인 -> IP 주소
67bool DomainAddrToIP(WCHAR* szDomain, IN_ADDR* pAddr);
68
69//void HandleError(const char* cause);
unsigned __int16 uint16
Definition CommTypes.h:9
void IN_ADDR_TO_STRING(const IN_ADDR &inAddr, char ipStr[INET_ADDRSTRLEN])
int InitWindowSocketLib(LPWSADATA)
Definition WinSocketAPI.cpp:3
SOCKET CreateWindowSocket_IPv4(bool isTCP, OUT int *errCode=NULL)
bool BindSocket(SOCKET &sock, SOCKADDR_IN &serverAddr, OUT int *errCode=NULL)
SOCKET AcceptSocket(SOCKET &sock, SOCKADDR_IN &clientAddr, OUT int *errCode=NULL)
bool ConnectToDestination(const SOCKET &sock, const SOCKADDR_IN &destAddr, OUT int *errCode=NULL)
bool ListenSocket(SOCKET &sock, int backlog, OUT int *errCode=NULL)
SOCKADDR_IN CreateDestinationADDR(const char *destIP, uint16 destPort)
Definition WinSocketAPI.cpp:45
SOCKADDR_IN CreateServerADDR_LoopBack(uint16 port)
Definition WinSocketAPI.cpp:182
SOCKADDR_IN CreateDestinationADDR_LoopBack(uint16 destPort)
Definition WinSocketAPI.cpp:74
bool DomainAddrToIP(WCHAR *szDomain, IN_ADDR *pAddr)
Definition WinSocketAPI.cpp:233
SOCKADDR_IN CreateServerADDR(const char *serverIp, uint16 port)
Definition WinSocketAPI.cpp:136
#define OUT
Definition WinSocketAPI.h:14
SOCKADDR_IN CreateServerADDR_ANY(uint16 port)
Definition WinSocketAPI.cpp:158
SOCKADDR_IN CreateDestinationADDR_byDomain(WCHAR *destDomain, uint16 destPort)
Definition WinSocketAPI.cpp:78