(C#,네트워크강좌)간단한 TCP 클라이언트/서버 구현, 멀티쓰레드 기반 에코우 클라이언트/서버_C추천#/WPF/자마린실무교육학원탑크리에듀(구로디지털단지역3번출구 2분거리)탑크리에듀(www.topcredu.co.kr) 제공 C#, Network 기초강좌 입니다. 이번 강좌는 클라이언트가 서버로 데이터만 전송하는 간단한 TCP 클라이언트 및 서버 작성부터 서버가 다시 클라이언트로 에코우 시키는 예제, 이를 멀티쓰레드로 변경하여 여러 클라이언트를 상대할 수 있도록 소스를 변경하여 적성된 예제 입니다. 동영상으로도 제작될 예정이며 동영상은 http://www.topcredu.co.kr 또는 http://www.facebook.com/topcredu.co.kr, http://ojc.asia 에서 확인하실 수 있습니다.
Ajax 기술문서 - 김연수Yeon Soo KimAjax 기술 문서(작성자 : 김연수)
(첫 회사에 입사하여 만든 사내 배포용 기술 문서)
Ajax In Action 도서를 참고하며 자료를 만들었으며, 이 자료를 만들면서 AJAX에 대한 많은 이해를 하게 됐던 거 같다.
작성일자는 잘못된 것이고, 2007년에 만들고 발표한 것으로 추정된다.
막하는 스터디 첫 번째 만남 Node.js연웅 조node.js를 처음 접하는 개발자를 위한 스터디 자료입니다.
실습 위주로, 간단한 웹 페이지를 만들어 보는 것을 목표로 하며,
express를 활용하기에 앞서, node.js 기본 API만으로 GET/POST 처리 방식을 알아봅니다.
내용의 깊이가 있지는 않으며, 단지 node.js의 입문을 위한 가벼운 수준으로 내용이 구성되었습니다.
Ajax 기술문서 - 김연수Yeon Soo KimAjax 기술 문서(작성자 : 김연수)
(첫 회사에 입사하여 만든 사내 배포용 기술 문서)
Ajax In Action 도서를 참고하며 자료를 만들었으며, 이 자료를 만들면서 AJAX에 대한 많은 이해를 하게 됐던 거 같다.
작성일자는 잘못된 것이고, 2007년에 만들고 발표한 것으로 추정된다.
막하는 스터디 첫 번째 만남 Node.js연웅 조node.js를 처음 접하는 개발자를 위한 스터디 자료입니다.
실습 위주로, 간단한 웹 페이지를 만들어 보는 것을 목표로 하며,
express를 활용하기에 앞서, node.js 기본 API만으로 GET/POST 처리 방식을 알아봅니다.
내용의 깊이가 있지는 않으며, 단지 node.js의 입문을 위한 가벼운 수준으로 내용이 구성되었습니다.
PHP 7의 새로운 특징과 기능 요약정아 손안녕하세요!
2016년도에 작성한 문서입니다.
기존에 PHP5에 익숙하신 분들이 새로이 PHP7이 나오면서,
간략하게 나마 무엇이 바뀌었는지,
그리고 PHP 프레임워크를 시작하기 전에 표준적인 코딩은 어떤 것인지 알아보기 위해 문서를 작성하였습니다.
많은 분들에게 도움이 되길 바라며!! ^^
* 참고 : PHP 5.5.9 이상 버전에서도 위 예제코드가 됩니다! >.<
Multi-thread : producer - consumerChang Yoon Oh기본적인 thread에 대한 접근법에서 Producer - Consumer의 여러가지 형태를 설명
2014-07-22 게시
2014-07-24 readwritelock 수정
2014-08-30 내용 추가
CRUD Pattern in AjaxRhio Kim모티브 :
웹 페이지에서 일어나는 사용자의 단일 액션에 대응하는 일련의 프로세스를 하나의 클래스에서 구현한다. 일련의 프로세스는 사용자가 서버에 요청을 하기 위해서 클릭을 한다거나 입력을 하고 요청을 하고 그에 따른 서버 측에서 처리가 이루어지고 처리 결과를 다시 사용자의 브라우저에 통보를 하고 브라우저는 결과를 통해 사용자에게 결과를 인식 시키는 일련의 작업을 말합니다.
목적 및 장점 :
1. CRUD(Create, Read, Update, Delete) 인터랙션에 대한 처리와 시스템 장애에 대한 빠른 문제 파악과 대응
조건 :
1. XHR Wrapped클래스가 존재하여야 한다. (prototype.js, dojo, jQuery, etc)
2. XHR 오브젝트를 이용한 데이터 처리가 있어야 한다.
3. 요청을 위한 단계와 응답에 대한 처리 단계가 간단하고 명료해야 한다.
제약 :
1. 복잡한 UI 처리 및 CRUD이외의 처리가 다소 병행되어 진다면 클래스 혹은 객체가 무거워질 수 있다.
단점 :
1. 특정한 인터랙션 위한 패턴으로 확장(extend) 및 소스 재사용 면에서 용이하지 못함
[211] 인공지능이 인공지능 챗봇을 만든다NAVER D2The document discusses various machine learning clustering algorithms like K-means clustering, DBSCAN, and EM clustering. It also discusses neural network architectures like LSTM, bi-LSTM, and convolutional neural networks. Finally, it presents results from evaluating different chatbot models on various metrics like validation score.
[244]로봇이 현실 세계에 대해 학습하도록 만들기NAVER D2The document discusses challenges with using reinforcement learning for robotics. While simulations allow fast training of agents, there is often a "reality gap" when transferring learning to real robots. Other approaches like imitation learning and self-supervised learning can be safer alternatives that don't require trial-and-error. To better apply reinforcement learning, robots may need model-based approaches that learn forward models of the world, as well as techniques like active localization that allow robots to gather targeted information through interactive perception. Closing the reality gap will require finding ways to better match simulations to reality or allow robots to learn from real-world experiences.
[243] Deep Learning to help student’s Deep LearningNAVER D2This document describes research on using deep learning to predict student performance in massive open online courses (MOOCs). It introduces GritNet, a model that takes raw student activity data as input and predicts outcomes like course graduation without feature engineering. GritNet outperforms baselines by more than 5% in predicting graduation. The document also describes how GritNet can be adapted in an unsupervised way to new courses using pseudo-labels, improving predictions in the first few weeks. Overall, GritNet is presented as the state-of-the-art for student prediction and can be transferred across courses without labels.
[234]Fast & Accurate Data Annotation Pipeline for AI applicationsNAVER D2This document provides a summary of new datasets and papers related to computer vision tasks including object detection, image matting, person pose estimation, pedestrian detection, and person instance segmentation. A total of 8 papers and their associated datasets are listed with brief descriptions of the core contributions or techniques developed in each.
Old version: [233]대형 컨테이너 클러스터에서의 고가용성 Network Load BalancingNAVER D2그림이 정상 출력되는 다음 링크의 자료를 확인해 주세요.
/deview/233-network-load-balancing-maglev-hashing-scheduler-in-ipvs-linux-kernel
[226]NAVER 광고 deep click prediction: 모델링부터 서빙까지NAVER D2This document presents a formula for calculating the loss function J(θ) in machine learning models. The formula averages the negative log likelihood of the predicted probabilities being correct over all samples S, and includes a regularization term λ that penalizes predicted embeddings being dissimilar from actual embeddings. It also defines the cosine similarity term used in the regularization.
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기NAVER D2The document discusses running a TensorFlow Serving (TFS) container using Docker. It shows commands to:
1. Pull the TFS Docker image from a repository
2. Define a script to configure and run the TFS container, specifying the model path, name, and port mapping
3. Run the script to start the TFS container exposing port 13377
[213] Fashion Visual SearchNAVER D2The document discusses linear algebra concepts including:
- Representing a system of linear equations as a matrix equation Ax = b where A is a coefficient matrix, x is a vector of unknowns, and b is a vector of constants.
- Solving for the vector x that satisfies the matrix equation using linear algebra techniques such as row reduction.
- Examples of matrix equations and their component vectors are shown.
[232] TensorRT를 활용한 딥러닝 Inference 최적화NAVER D2This document describes the steps to convert a TensorFlow model to a TensorRT engine for inference. It includes steps to parse the model, optimize it, generate a runtime engine, serialize and deserialize the engine, as well as perform inference using the engine. It also provides code snippets for a PReLU plugin implementation in C++.
[242]컴퓨터 비전을 이용한 실내 지도 자동 업데이트 방법: 딥러닝을 통한 POI 변화 탐지NAVER D2[242]컴퓨터 비전을 이용한 실내 지도 자동 업데이트 방법: 딥러닝을 통한 POI 변화 탐지
[212]C3, 데이터 처리에서 서빙까지 가능한 하둡 클러스터NAVER D2[212]C3, 데이터 처리에서 서빙까지 가능한 하둡 클러스터
[223]기계독해 QA: 검색인가, NLP인가?NAVER D2The document discusses machine reading comprehension (MRC) techniques for question answering (QA) systems, comparing search-based and natural language processing (NLP)-based approaches. It covers key milestones in the development of extractive QA models using NLP, from early sentence-level models to current state-of-the-art techniques like cross-attention, self-attention, and transfer learning. It notes the speed and scalability benefits of combining search and reading methods for QA.
2. 지난 3주차에 Retrofit(or OkHttp)와 비슷한 통신모듈인 HttpRequest를 이용하여 서버와 통신
하는 방법을 알아봤습니다. 이번 세션에서는 Retrofit2을 설명하려 했지만, Retrofit2 오픈 소스를
열어보니 대부분 OkHttp3.*의 기능을 wrap해 놓은 것이기 때문에 OkHttp로 세션주제를 변경했습
니다. (좀 더 도움이 되는 방향으로 해야 하니까!)
또한 OkHttp를 공부하며 모든 부분을 알려드리고 싶었지만 주어진 시간 내에 모든 클래스를 분
해해서 함께 이야기 나누기에는 시간이 부족함을 느꼈습니다. 그래서 핵심적인 부분인 GET 방식
만 보고 갈 예정입니다. 아! 많은 분들이 OkHttp를 이야기하면 OkHttp는 클래스 이름으로 많이
인식하고 계시는 것 같습니다. 하지만 OkHttp는 패키지 이름이며, OkHttpClient가 핵심 클래스인
것을 알려드립니다~!
3. 지금부터 공부할 OkHttp3.*의 Request Process 관련 Class
1. Request + Request.Builder(Nested)
2. OkHttpClient + OkHttpClient.Builder(Nested)
3. Response + Response.Builder(Nested)
OkHttp를 사용하여 서버와 통신을 하기 위해선 최소 이 3개의 클래스에 대해서 꼭 이해하셔
야 합니다. 이번 세션에서는 이 세 개의 클래스를 설명해드릴 예정입니다. 아! 세 클래스 모두
Builder 패턴이 적용되어 Builder라는 Nested Class를 포함하고 있습니다.
1. Request+Request.Builder(Nested)
Request 클래스는 String 타입의 method, Object 타입의 tag를 비롯하여 OkHttp3 패키지의
HttpUrl, Headers, RequestBody 세 가지 클래스를 멤버 필드로 가지고 있습니다.
여기에서 HttpUrl을 보면서 두 가지의 신기한 점이 있었습니다 기존에 우리가 알고 있는 정보
는 HTTP 프로토콜은 80번 포트를 사용하고 있다는 것을 다들 알고 있으셨을 텐데요. 그럼 HTTPS
는 몇 번 포트를 사용할까요? 바로 443번 포트를 이용합니다. 평소 브라우저에서 URL을 이용하여
HTTPS Request을 보내도 443번 포트를 작성하지 않아도 요청이 잘 날라갔는데요. HTTP over SSL
의 port로써 TCP에서만 사용 가능한 포트번호라 하네요. 또한 HttpUrl 클래스도 java.net.URL 클래
스를 wrap하여 만든 클래스입니다. 이 점은 HttpRequest와 비슷한 부분이 많죠?
더불어 Headers와 RequestBody는 이름에서 알 수 있듯이 Request의 정보를 볼 수 있도록 지
원해주는 클래스입니다.
4. 2. OkHttpClient +OkHttpClient.Builder
저는 이 클래스가 OkHttp의 핵심 모듈이 아닐까 생각합니다. OkHttpClient는 실행 준비가 된
call들을 위한 Factory로 HTTP 요청들을 보내고 이 요청들에 대한 응답을 듣는 데 사용되기 때문
입니다.
OkHttpClient 클래스(이하 OkHttpClient)는 public null constructor와 Override된 private
constructor를 가지고 있습니다. 때문에 public null constructor를 이용하여 OkHttpClient객체를 생
성해야 하는데 이 때 Builder에 지정되어있는 default value로 객체를 생성하게 됩니다.
이렇게 생성되는 OkHttpClient는 프로그램 내 모든 HTTP call들을 위한 단일 객체로 사용하기를
OkHttp3.* 스펙에서 권장하고 있습니다. OkHttpClient의 멤버 중 Connection Pool과 Thread Pool
5. 을 가지고 있는데 클라이언트가 각각의 요청마다 새로운 OkHttpClient를 생성하게 되면 많은 시
간과 메모리를 잡아먹기 때문이죠.
서버와 통신하기 전 설정해줘야 하는 값들이 있었던 개발자 분들은 Retorofiit2.*에서
interceptor 를 등록했었던 경험이 있으실 겁니다. OkHttpClient는 Interceptor와
NetworkInterceptor 를 등록할 수 있습니다. (OkHttp의 기능이였네요!)
OkHttpClient는 customize를 할 수 있도록 자체적으로 newBuilder() 메소드를 제공합니다. 이는
싱글톤 패턴이 적용되어 있는 OkHttpClient에 Connection pool, Thread pool, configuration을 유연
하게 공유할 수 있도록 지원해 줍니다. (default로 지정되어 있는 timeout - 1000ms를 변경할 수
도 있습니다!)
OkHttpClient는 요청을 전송하기 위해선 okhttp3패키지의 Dispatcher클래스(이하 Dispatcher)가
필요합니다. Dispatcher는 각 요청마다 비동기적으로 요청을 전송하라는 정책이 있습니다.(안드로
이드의 특화 구현되어 있기 때문이죠 출처-D2) 각각의 Dispatcher는 내부적으로
java.util.concurrent.ExecutorService 클래스를 사용합니다. Dispatcher는 조금 생소한 자료구조
Deque(덱 - Queue에서 앞/뒤로 데이터를 삽입/삭제 할 수 있는 자료구조를)을 사용하여 각각의
요청객체를 저장합니다. Dispatcher의 default Request는 64번으로 지정되어 있습니다.(2의 제곱거
듭제곱! 싱기방기?)
Dispatcher를 이용하여 최종적으로 요청을 보내기 위해선 RealCall 클래스가 필요합니다.(RealCall
클래스는 API에 존재하지 않음.) 클래스의 이름답게 실제로 요청이 이루어지는 클래스죠.
RealCall클래스에 execute메소드는 사용자의 요청을 보내기 전에 설정해 주었던 Interceptor를 설
정해 주고 Resposne객체를 Return 받는 역할을 합니다.
7. 이 부분을 클래스다이어그램으로 나타나면 다음과 같습니다. 메소드는 생략했으며 꼭 알아야 할
3개의 클래스와 더불어 실제 Request를 전송하고 Response를 받는 클래스들의 멤버필드만 표기
했습니다.
사용법
Request 클래스는 Builder 디자인패턴이 적용되어 있기 때문에 new RequestBuilder() 로 접근해야
합니다. 또한 setUrl()메소드가 존재하지 않기 때문에 url(url : String) 메소드를 호출하여 url을
setting해줍니다. (전달인자를 java.net.URL로 넣어줘도 됩니다.) 이 과정에서 CacheControl을 설정
해 주거나 Header정보를 설정해 주는 등. 간단한 세팅을 해줄 수 있습니다.
이렇게 만들어진 request객체를 OkHttpRequest의 Call객체(구현체 – RecalCall)를 만들며 Response
의 콜백을 등록합니다. 또한 enqueuer 해주는 작업에서 내부적으로 ThreadPoolExecutor의 worker
Thread에게 요청을 떠맡기게 됩니다.
Request
-url: HttpUrl
-method: String <<default : get>>
-headers: Headers
-body: RequestBody
-tag: Object Request.Builder
<<static,nested>>
OkHttpClient
~dispatcher: Dispatcher
~proxy: Proxy
~protocals: List<Protocals>
~interceptors: List<Interceptor>
~networkInterceptors: List<interceptor>
~proxySelector: ProxySelector
~cookieJar: CookieJar
~cache: Cache
~internalCache: InternalCache
~socketFactory: SocketFactory
~certificationChainCleaner: CertificateChainCleaner
~hostnameVerifier: HostnameVerifier
~certificatePinner: CertificatePinner
~proxyAuthenticator: Authenticator
~authenticator: Authenticator
~connectionPool: ConnectionPool
~dns: DNS
Response
-request: Request
-protocal: Protocol
-code: int
-message: String
-handshake: Handshake
-headers: Headers
-body: ResponseBody
-networkResponse: Response
-cacheResponse: Response
-priorResponse: Response
-sentRequestAtMillis: long
-receivedResponseAtMillis: long
-cacheControl: CacheControl
Dispatcher
-maxRequests: int <<default:64>>
-maxRequestPerHost: int <<default:5>>
-idleCallback: Runnable
-executorService: ExecutorService
-readyAsyncCalls: Deque<AsyncCall>
-runningAsyncCalls: Deque<AsyncCall>
-runningSyncCalls: Dequeue<RealCall>
OkHttpClient.Builder
<<static,nested>>
RealCall
-client: OkHttpClient
-retryAndFollowUpInterceptor: RetryAndFollowUpInterceptor
RetryAndFollowUpInterceptor
Response.Builder
okhttp3.Call
<<interface>>
RequestBody
ResponseBody
8. 요청에 대한 응답코드가 200,300번일 경우 onResponse 메소드가 호출됩니다. onResponse메소드
의 전달인자 중 Response 객체가 있는데요. 이 객체를 이용하여 많은 행동을 할 수 있습니다. (자
세하신건 API를 읽어주시길 원합니다)
.
안드로이드에서 UI Thread가 아닌 다른 Thread에서 UI의 data를 handling할 경우 Exception이 발
생하니 runOnUiThread()를 호출해야 하는 건 상식이죠!
감사합니다.