티스토리 뷰

728x90


아래 emulator을 이용한 TCP와 UDP 소스코드



목적 Object

Emulator 3개를 이용하여 TCP와 UDP의 통신을 한다.
Emulator에 접속하여 소문자를 대문자로 변환하는 소스코드를 짠다.
communicate between TCP and UDP using 3 Emulators connect Emulator, write down source code which change small letters and capital letters add port using telnet,for communication of emulators 

----------------------------------------------------------------------------------

emulator간 TCP와 UDP 통신을 하기 위해서는 Telnet을 이용하여 포트를 추가해주어야 합니다.
포트 추가하기 전에 몇 가지 설명 드리겠습니다.
먼저 emulator의 포트번호는 각 emulator가 구동되면서 발생하는 emulator 번호입니다.
아래는 제가 사용한 emulator 입니다.
5554, 5556, 5558 이렇게 3가지입니다.
before adding Port, i will explan something
first, emulator's port number is emulator number that occur when emulator start to operate
for example,
There are 3 number : 5554, 5556, 5558


3가지의 5554, 5556, 5558 번은 emulator의 번호이면서 접근 할 수 있는 포트 번호입니다.
이 emulator의 포트번호를 이용하여 포트번호를 열어줘야 합니다.
열어주는 방법은 아래와 같습니다.
Those are numbers that can connect to emulator.
After then, open Port number using emulator's Port numbers (ex, 5554,5556,5558)
how to open 

명령어 : redir add tcp:7000:7000
tcp:외부에서 접근 포트:emulator 포트

여기서 TCP 외부, 내부 포트는 7000로 설정하였습니다. 

tcp:connecting Port from exterior:emulator Port 
I can open tcp port using 7000 

명령어 : redir add udp:8000:8000
udp:외부에서 접근 포트:emulator 포트

여기서 UDP 외부, 내부 포트는 8000으로 설정하였습니다. 

udp:connecting port from exterior :emulator port 
I can open udp port using 8000 


emulator와 emulator 간은 외부 접근 포트를 위의 방법대로 열어줘야 접근이 가능합니다.
자바 코드에서 emulator로의 접근도 위의 방법을 사용해야 할 수 있습니다.
if you follow this way, you can connect well!!
if you use jaza code, follow this way, too! 

----------------------------------------------------------------------------------

소스 코드상에서 처리
IP주소는 아래내용을 참고 하세요
- process in source code
refer to contents
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개의 emulator는 IP주소가 10.0.2.2 번으로 접근할수 있습니다.
클라이언트에서 접근을 위해서는 10.0.2.2번으로 설정하시고 TCP와 UDP 포트번호를 지정하시면 됩니다. 
다시 정리하자면 10.0.2.2번으로 접속하는 클라이언트를 만들어주시면 되고포트번호는 telnet을 이용하여 add해주시면 됩니다.
two emulators operating server can connect through ip address 10.0.2.2
to connect to client, set up 10.0.2.2 and appoint tcp and udp port number.
in short, make client that connect to 10.0.2.2 and add port using telnet

----------------------------------------------------------------------------------

구동화면 Start-up image




댓글