3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UDPを使う際、inet_addr()でC4996エラーが出るときの対処方法

Last updated at Posted at 2017-10-11

InetPton()関数を代わりに使おう

PCTSTR WSAAPI inet_pton(
    INT Family,
    PCTSTR pszAddrString,
    PVOID pAddrBuf
);

  • 第1引数 : Family
    IPv4を使うなら"AF_INET"、IPv6を使うなら"AF_INET6"

  • 第2引数 : pszAddrString
    IPアドレスを格納している文字列のポインタ

  • 第3引数 : pAddrBuf
    バイナリ形式に変換したIPアドレスを格納するバッファのポインタ

#include <winsock2.h>
#include <ws2tcpip.h>

void Send_Packet()
{

sockaddr_in addr;
addr.sin_family = AF_INET;

~中略~

//IP アドレスの変換
InetPton( addr.sin_family, _T("127.0.0.1"), &addr.sin_addr.S_un.S_addr );

~中略~

}

参考ページ: https://msdn.microsoft.com/ja-jp/library/windows/desktop/cc805844

3
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?