Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- sourcetree_authencicationfailed
- xcode_targeting
- unreal_binaryselection
- appcenter대체
- sourcetree_accessdenied
- Unity2022
- owasp_depdendency_check_shell
- jenkins_owasp
- unreal_contentmanagement
- unrealbuildshellscript
- molocon24
- xcode-select_jeknins
- unrealbuildcommand
- jenkins_role관리_플러그인
- apkipa업로드저장소
- unity package_androidlib
- molocon24후기
- jenkins_sudo
- molocon24내용정리
- python3.12.4
- cookcontent
- jenkins_계정삭제
- dxt
- etc2
- owasp_dependency_check
- unreal_flavorselection
- unreal_android_빌드옵션
- python_distutils_module_missing
- ChatGPT
- asset database_androidlib
Archives
- Today
- Total
mystic-agit 개발 블로그
[RemoteAccess] 모바일에서 Windows Application 원격 제어하는 시스템 구현 - Server 구현 (3) 본문
Platform/RemoteAccess
[RemoteAccess] 모바일에서 Windows Application 원격 제어하는 시스템 구현 - Server 구현 (3)
mystic-agit 2024. 8. 21. 17:21
목 차 1. 시스템 조건 2. 주요 코드 3. Github |
앞서 '시스템 구상'에서 계획하였던
input 데이터를 먼저 수신하고
Windows Application으로 송신하는 Server를 구성하였다.
1. 시스템 구상
- Python 코드로 구현
- 여러 클라이언트가 접속할 수 있게 관리
- Mobile Application에서 받은 데이터를 연결된 모든 클라이언트에 송신
2. 주요 코드
import socket
import threading
# 전역 클라이언트 목록
clients = []
def broadcast(message):
for client_socket in clients:
try:
client_socket.send(message.encode('utf-8'))
except:
# 오류가 발생한 클라이언트는 목록에서 제거
clients.remove(client_socket)
def handle_client(client_socket):
global clients
clients.append(client_socket)
print(f"Client connected: {client_socket}")
while True:
try:
message = client_socket.recv(1024).decode('utf-8')
if not message:
break
print(f"Received message: {message}")
# 메시지를 모든 클라이언트에게 브로드캐스트
broadcast(message)
except ConnectionResetError:
break
print(f"Client disconnected: {client_socket}")
clients.remove(client_socket)
client_socket.close()
def main():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('00.00.000.00', 12345)) // TODO : 서버 ip 및 포트
server.listen(5)
print("Server listening on port 12345")
while True:
client_socket, addr = server.accept()
print(f"Accepted connection from {addr}")
# 각 클라이언트 연결을 새로운 스레드에서 처리
client_handler = threading.Thread(target=handle_client, args=(client_socket,))
client_handler.start()
if __name__ == "__main__":
main()
3. Github
'Platform > RemoteAccess' 카테고리의 다른 글
Comments