ssize_t send(int socket, const void *buffer, size_t length, int flags);
Buffer type is void.
2. recv()
ssize_t recv(int sockfd, void *buf, size_t len, int flags);
3. Struct example
//sturuct
struct Matrix {
int row;
int col;
};
//memory allocation
struct Matrix *mat = (struct Matrix*)malloc(sizeof(struct Matrix)*2);
mat[0].row=10;
mat[0].col=10;
//send
send(sock_desc,mat,strlen(mat),0);
4. pthread_create()
#include <pthread.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
compile: gcc -lpthread -o server mserver.c
5. Difference between thread and process.
http://xenostudy.tistory.com/230 (Korean site)
6. Reference
send(): http://pubs.opengroup.org/onlinepubs/009695399/functions/send.html
receive(): http://man7.org/linux/man-pages/man2/recvmsg.2.html
receive(): http://man7.org/linux/man-pages/man2/recvmsg.2.html
pthread_create(): http://man7.org/linux/man-pages/man3/pthread_create.3.html
http://itguru.tistory.com/100
http://itguru.tistory.com/100
http://en.wikipedia.org/wiki/Struct_(C_programming_language)
댓글 없음:
댓글 쓰기