소켓
-
[소켓프로그래밍] 4. 고정길이, 가변길이 데이터 TCP 통신 / 데이터 전송 후 종료윈도우 소켓 프로그래밍 2024. 8. 24. 17:51
이 게시글은 'TCP/IP 윈도우 소켓 프로그래밍 (김선우 저, 한빛아카데미)'를 공부한 내용을 기반으로 작성됨TCP Server-client의 기본 구조는 직전 게시글에서 다룬 구조로 정해져 있다.따라서 직전 게시글의 코드 구조를 한 번 이해하고 나면 이를 마스터 코드로 두고 그대로 재사용 할 수 있다.그렇다면, 마스터 코드의 어느 부분을 바꾸어야 또 다른 응용 프로그램을 만들 수 있는 것일까?바로 '데이터 처리' 부분이다. 어떤 데이터를 어떤 형식으로 주고 받으며 처리할지를 결정하는 것이 바로 네트워크 응용 프로그램 개발자의 역할이다. 이번 게시글에서는 직전 게시글의 마스터 코드를 기반으로 고정길이 데이터 전송과 가변길이 데이터 전송을 수행해보도록 한다.고정길이 데이터 전송은 Server와 Clie..
-
[소켓프로그래밍] 3. TCP 서버 클라이언트 통신윈도우 소켓 프로그래밍 2024. 8. 24. 16:52
이 게시글은 'TCP/IP 윈도우 소켓 프로그래밍 (김선우 저, 한빛아카데미)'를 공부한 내용을 기반으로 작성됨 책 2부로 넘어오자마자 굉장히 재밌는 실습이 나를 반긴다.. 그것은 바로 TCP server-client 통신 TCP server-client 통신은 위 도식과 같이 진행된다. 차례대로 알아보도록 하자. Server - socket() : socket()은 네트워크 프로그래밍에서 '소켓'을 생성하기 위한 함수. 소켓은 네트워크 통신의 endpoint를 의미하며, 소켓을 통해 서버-네트워크 혹은 컴퓨터-컴퓨터 간 데이터 통신이 가능해진다.Server - bind() : bind()는 소켓을 특정 IP 주소의 포트 번호에 연결하기 위해 사용됨. 소켓을 생성한 후에, 서버 소켓이 특정 IP 주소..
-
[소켓프로그래밍] 1. 소켓 생성과 닫기, 바이트 정렬윈도우 소켓 프로그래밍 2024. 8. 16. 17:30
이 게시글은 'TCP/IP 윈도우 소켓 프로그래밍 (김선우 저, 한빛아카데미)'를 공부한 내용을 기반으로 작성됨 #define _WINSOCK_DEPRECATED_NO_WARNINGS // winsock c4996 처리#include #include #include using namespace std;#pragma comment(lib,"ws2_32.lib") // ws2_32.lib 라이브러리를 링크void err_quit(LPCTSTR msg){ LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRA..