C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[10428] Re:[참고] IPAddress String -> Long / IPAddress Long -> String 변환
최보현.U&I [uriduri] 1890 읽음    2001-08-29 20:45

inet_ntoa
The Windows Sockets inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.

char FAR * inet_ntoa (
  struct in_addr in 
);

Parameters
in
[in] A structure that represents an Internet host address.
Remarks
The inet_ntoa function takes an Internet address structure specified by the in parameter and returns an ASCII string representing the address in ".'' (dot) notation as in "a.b.c.d''. The string returned by inet_ntoa resides in memory that is allocated by Windows Sockets. The application should not make any assumptions about the way in which the memory is allocated. The data is guaranteed to be valid until the next Windows Sockets function call within the same thread, but no longer. Therefore, the data should be copied before another Windows Sockets call is made.

Return Values
If no error occurs, inet_ntoa returns a char pointer to a static buffer containing the text address in standard ".'' notation. Otherwise, it returns NULL.

QuickInfo
  Windows NT: Yes
  Windows: Yes
  Windows CE: Use version 1.0 and later.
  Header: Declared in winsock2.h.
  Import Library: Link with ws2_32.lib.

See Also
inet_addr

----------------------------------------------------------------------------------------------------inet_addr
The Windows Sockets inet_addr function converts a string containing an (Ipv4) Internet Protocol dotted address into a proper address for the IN_ADDR structure.

unsigned long inet_addr (
  const char FAR * cp 
);

Parameters
cp
[in] A null-terminated character string representing a number expressed in the Internet standard ".'' (dotted) notation.
Remarks
The inet_addr function interprets the character string specified by the cp parameter. This string represents a numeric Internet address expressed in the Internet standard ".'' notation. The value returned is a number suitable for use as an Internet address. All Internet addresses are returned in IP's network order (bytes ordered from left to right).

Internet Addresses

Values specified using the ".'' notation take one of the following forms:

a.b.c.d a.b.c a.b a

When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address. When an Internet address is viewed as a 32-bit integer quantity on the Intel architecture, the bytes referred to above appear as "d.c.b.a''. That is, the bytes on an Intel processor are ordered from right to left.

The parts that make up an address in "." notation can be decimal, octal or hexidecimal as specified in the C language. Numbers that start with "0x" or "0X" imply hexidecimal. Numbers that start with "0" imply octal. All other numbers are interpreted at decimal.

"4.3.2.16"  decimal
"004.003.002.020"  octal
"0x4.0x3.0x2.0x10"  hexidecimal
"4.003.002.0x10"  mix


Note The following notations are only used by Berkeley, and nowhere else on the Internet. In the interests of compatibility with their software, they are supported as specified.

When a three part address is specified, the last part is interpreted as a 16-bit quantity and placed in the right most two bytes of the network address. This makes the three part address format convenient for specifying Class B network addresses as "128.net.host''.

When a two part address is specified, the last part is interpreted as a 24-bit quantity and placed in the right most three bytes of the network address. This makes the two part address format convenient for specifying Class A network addresses as "net.host''.

When only one part is given, the value is stored directly in the network address without any byte rearrangement.

Return Values
If no error occurs, inet_addr returns an unsigned long value containing a suitable binary representation of the Internet address given. If the string in the cp parameter does not contain a legitimate Internet address, for example if a portion of an "a.b.c.d" address exceeds 255, inet_addr returns the value INADDR_NONE.

QuickInfo
  Windows NT: Yes
  Windows: Yes
  Windows CE: Use version 1.0 and later.
  Header: Declared in winsock2.h.
  Import Library: Link with ws2_32.lib.

See Also
inet_ntoa



+ -

관련 글 리스트
10400 [만해][질문]Table에서 메모리 에러 강재호 1037 2001/08/29
10428     Re:[참고] IPAddress String -> Long / IPAddress Long -> String 변환 최보현.U&I 1890 2001/08/29
10431         Re:Re:[참고] IPAddress String -> Long / IPAddress Long -> String 변환 강재호 1784 2001/08/29
10434             Re:Re:Re:[참고] IPAddress String -> Long / IPAddress Long -> String 변환 최보현.U&I 1178 2001/08/29
10417     Re:[만해][질문]Table에서 메모리 에러 개박살.U&I 1033 2001/08/29
10423         Re:Re:[만해][질문]Table에서 메모리 에러 강재호 917 2001/08/29
10427             Re:Re:Re:[만해][질문]Table에서 메모리 에러 최보현.U&I 999 2001/08/29
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.