새소식

반응형
App/Android

[Android] 에뮬레이터 localhost 가 10.0.2.2로 인식되는 이유

  • -
반응형

2023-12-15


사진: Unsplash 의 NEOM


1. 이유

 

에뮬레이터의 각 가상 라우터 머신이 10.0.2/24 아이피 대역대를 가지고 동작하기 때문이다. 각 에뮬레이터의 사전에 예약된 아이피 주소들은 아래와 같다. 아래 나와 있듯이 10.0.2.2 에 요청을 보낼 시 호스트로 루프백을 보내는 것을 알 수 있다.

 

10.0.2.1    Router/gateway address
10.0.2.2    Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)
10.0.2.3    First DNS server
10.0.2.4 / 10.0.2.5 / 10.0.2.6  Optional second, third and fourth DNS server (if any)
10.0.2.15   The emulated device's own network/ethernet interface
127.0.0.1   The emulated device's own loopback interface

2. 출처

 

https://stackoverflow.com/questions/9808560/why-do-we-use-10-0-2-2-to-connect-to-local-web-server-instead-of-using-computer

 

why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client

We normally use 10.0.2.2:(port number) in the url to connect to the local web server,but we should use the computer's ip address instead of 10.0.2.2 Then why do we use 10.0.2.2?

stackoverflow.com


메인 이미지 출처 : 사진: UnsplashNEOM

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.