목록2025/09 (3)
아!두이노, 라즈베리, 코딩 노가다
#include #include #include #include #include #include #define BUF_SIZE 30void error_handling(char *message);int main(int argc, char *argv[]){ int serv_sock; char message[BUF_SIZE]; int str_len; socklen_t clnt_adr_sz; struct sockaddr_in serv_adr, clnt_adr; if(argc!=2){ printf("Usage : %s \n", argv[0]); exit(1); } serv_sock=socket(PF_INET, SOCK_DGRAM, 0); if(serv_sock==-1) error_handling("UDP..
import socketimport sys# 실행 파일명 뒤에 포트 번호가 인수로 전달되는지 확인if len(sys.argv) != 2: print("사용법: python script.py ")else: PORT = sys.argv[1] try: PORT = int(port) print(f"서버가 포트 {port}에서 실행됩니다.") except ValueError: print("포트 번호는 숫자여야 합니다.")# 서버 주소와 포트HOST = "0.0.0.0" # 모든 IP에서 수신# 소켓 생성 (IPv4, UDP)sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)sock.bind((HOST, ..
#if defined(_DEBUG)#define _CRTDBG_MAP_ALLOC // 디버그 할당을 사용하겠다는 선언#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) // 덤프를 좀 더 쉽게 보기 위한 것#endif// Memory block identification// #define _FREE_BLOCK 0// #define _NORMAL_BLOCK 1// #define _CRT_BLOCK 2// #define _IGNORE_BLOCK 3// #define _CLIENT_BLOCK 4// #define _MAX_BLOCKS 5// 다른 건 별로 의미 없고 _NORMAL_BLOCK과 _CLIENT_BLOCK만 알면됨#..