분류 전체보기453 구조체 사용 server #include #include #include #include #include #include #include #include #define BUF_SIZE 100 #define SERVER_IP INADDR_ANY #define SERVER_PORT "7777" //구조체 struct user { // < 여기 적어주는 _STUDENT 는 코드상 큰 의미는 없다. 하지만 적어주는 이유는 구조체가 중복되어 코딩되는 것을 방지하기 위해 관례적으로 적어준다. char id[20]; char sock_num; }; struct user us[20]; void error_handling(char *buf); int main(/*int argc, char *argv[]*/) { int sock_ch.. 2020. 10. 8. 구조체 #include #include int main() { // 구조체(사용자가 정의한 타입) 정의 struct bibim{ int a; float b; char c; char d[5]; }; struct bibim b1, b2; // 구조체 변수 선언 //구조체 멤버변수에 값 저장 b1.a = 10; b1.b =1.1f; b1.c = 'A'; strncpy(b1.d, "ABCDE", 5); b2.a = 100; b2.b = 10.1f; b2.c = 'B'; strncpy(b2.d, "hello", 5); printf("--------b1 struct--------\n"); printf("a: %d\n", b1.a); printf("b: %f\n", b1.b); printf("c: %c\n", b1.c); .. 2020. 10. 6. enterID - 개행문자 없애기 echo_selectserv.c #include #include #include #include #include #include #include #include #define BUF_SIZE100 #define SERVER_IPINADDR_ANY #define SERVER_PORT"9987" void error_handling(char *buf); int main(/*int argc, char *argv[]*/) { int serv_sock, clnt_sock; struct sockaddr_in serv_adr, clnt_adr; struct timeval timeout; fd_set reads, cpy_reads; socklen_t adr_sz; int fd_max, str_len, fd_num, i;.. 2020. 10. 6. 다이아몬드 / 모래시계 2020. 10. 5. echo_client.c echo_selectserv.c echo_selectserv.c #include #include #include #include #include #include #include #include #define BUF_SIZE100 #define SERVER_IPINADDR_ANY #define SERVER_PORT"9987" void error_handling(char *buf); int main(/*int argc, char *argv[]*/) { int serv_sock, clnt_sock; struct sockaddr_in serv_adr, clnt_adr; struct timeval timeout; fd_set reads, cpy_reads; socklen_t adr_sz; int fd_max, str_len, fd_num, i;.. 2020. 9. 29. echo_selectserv echo_client echo_selectserv.c #include #include #include #include #include #include #include #include #define BUF_SIZE 100 void error_handling(char *buf); int main(int argc, char *argv[]) { int serv_sock, clnt_sock; struct sockaddr_in serv_adr, clnt_adr; struct timeval timeout; fd_set reads, cpy_reads; socklen_t adr_sz; int fd_max, str_len, fd_num, i; char buf[BUF_SIZE]; if(argc!=2) { printf("Usage : %s \n".. 2020. 9. 29. 콘덴서에 대한 설명 youtu.be/oD4R0dG6qoQ 2020. 9. 28. chpt12. echo_select #include #include #include #include #include #include #include #include #define BUF_SIZE 100 void error_handling(char *buf); int main(int argc, char *argv[]) { int serv_sock, clnt_sock; struct sockaddr_in serv_adr, clnt_adr; struct timeval timeout; fd_set reads, cpy_reads; socklen_t adr_sz; int fd_max, str_len, fd_num, i; char buf[BUF_SIZE]; if(argc!=2) { printf("Usage : %s \n", argv[0]); exit(1.. 2020. 9. 25. echo_server.c echo_client.c echo_server.c #include #include #include #include #include #include #define BUF_SIZE 1024 void error_handling(char *message); int main(int argc, char *argv[]) { int serv_sock, clnt_sock; char message[BUF_SIZE]; int str_len, i; struct sockaddr_in serv_adr; struct sockaddr_in clnt_adr; socklen_t clnt_adr_sz; if(argc!=2) { printf("Usage : %s \n", argv[0]); exit(1); } serv_sock=socket(PF_INET, SOCK_.. 2020. 9. 24. hello server (client ->server) hello_client.c #include #include #include #include #include #include #define SERVER_IP"127.0.0.1" #define SERVER_PORT "9988" void error_handling(char *message); int main(int argc, char* argv[]) { int serv_sock; int clnt_sock; int sock; struct sockaddr_in serv_addr; //char message[30] = {0,}; //초기화 하는것이 더 좋다 int str_len = 0; //초기화 하는것이 더 좋다 /* if(argc!=3){ printf("Usage : %s \n", argv[0]); exit(1.. 2020. 9. 24. hello server (client ->server) hello_client.c #include #include #include #include #include #include #define SERVER_IP"127.0.0.1" #define SERVER_PORT "9988" void error_handling(char *message); int main(int argc, char* argv[]) { int serv_sock; int clnt_sock; int sock; struct sockaddr_in serv_addr; //char message[30] = {0,}; //초기화 하는것이 더 좋다 int str_len = 0; //초기화 하는것이 더 좋다 /* if(argc!=3){ printf("Usage : %s \n", argv[0]); exit(1.. 2020. 9. 23. Sever socket created Sever socket binding Sever socket listening hello_server.c #include #include #include #include #include #include #define SERVER_IP INADDR_ANY #define SERVER_PORT "9988" void error_handling(char *message); int main(int argc, char *argv[]) { int serv_sock; int clnt_sock; struct sockaddr_in serv_addr; struct sockaddr_in clnt_addr; socklen_t clnt_addr_size; char message[]="Hello World!"; /* if(argc!=2){ printf("Usage : %s \n", argv[0]); exit(.. 2020. 9. 23. c언어 소켓통신 hello_client.c #include #include #include #include #include #include void error_handling(char *message); int main(int argc, char* argv[]) { int sock; struct sockaddr_in serv_addr; char message[30]; int str_len; if(argc!=3){ printf("Usage : %s \n", argv[0]); exit(1); } sock=socket(PF_INET, SOCK_STREAM, 0); if(sock == -1) error_handling("socket() error"); memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_f.. 2020. 9. 23. C언어 소켓통신 hello_server.c https://m.blog.naver.com/PostView.nhn?blogId=wndrlf2003&logNo=220001255564&proxyReferer=https:%2F%2Fwww.google.com%2F 네트워크기초 11주차(2) (TCP/IP 1:1 에코서버 C로 작성, 클라이언트 대기 방식) > 네트워크기초 11주차(2) (TCP/IP 1:1 에코서버 C로 작성, 클라이언트 대기 방식) └ 접기 blog.naver.com #include // ANSI C #include // ANSI C #include // ANSI C #include // unix 표준 #include //버클리 소켓 #include //소켓 기본 void error_handling(char* message); int ma.. 2020. 9. 23. 알고리즘 대각선배열 2020. 9. 21. analogWrite() 함수 Description Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady rectangular wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin. You do not need to call pinMode() to set the pi.. 2020. 9. 18. 초음파센서 ultrasonic sensor + LED + buzzer(tone 함수) https://blog.naver.com/ann_arbor/221361752643 아두이노 기초 - 초음파 센서 사용하기 (pulseIn 함수) [2017. 8. 15 작성]최근 pulseIn 함수를 찾아 볼 일이 있었는데 또 필요할 때가 있을것 같아 정리해 둔다.... blog.naver.com 거리 : float 형이나 long 형으로 선언 //초음파 센서의 핀번호를 설정한다. int echoPin = 2; int trigPin = 3; int buzzer = 6; void setup() { Serial.begin(9600); // trig를 출력모드로 설정, echo를 입력모드로 설정 pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzze.. 2020. 9. 18. RGB LED 랜덤함수 pinMode(2, OUTPUT); 아날로그에 연결 했을때는 핀모드 입력 해주나 안해주나 똑같이 동작한다 int BLUE = 11; int GREEN = 10; int RED = 9; int i; long randNumber; void setup() { //pinMode(BLUE, HIGH);//BLUE //pinMode(GREEN, HIGH);//GREEN //pinMode(RED, HIGH);//RED randomSeed(analogRead(0)); Serial.begin(9600); } void loop() { i = random(1,256); Serial.println(i); analogWrite(BLUE, i); i = random(1,256); Serial.println(i); analogWr.. 2020. 9. 18. JMOD-BT-01 블루투스 모듈 / dht11 / MIT App Inventor https://appinventor.mit.edu/ MIT App Inventor | Explore MIT App Inventor File Path Updates Starting with Android 10 Android 10 changes how applications can store data. If you use the File component you will want to read this blog entry which discusses how MIT App Inventor is adapting to this change. More appinventor.mit.edu https://firebase.google.com/ Firebase Firebase는 고품질 앱을 빠르게 개발하고 비즈니스를 성장.. 2020. 9. 16. blynk dht11 /************************************************************* Download latest Blynk library here: https://github.com/blynkkk/blynk-library/releases/latest Blynk is a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets. Downloads, docs, tutorials:.. 2020. 9. 16. 이전 1 ··· 13 14 15 16 17 18 19 ··· 23 다음