[ #include <sys/types.h> ] [ #include <sys/socket.> ] accept() |
int accept(int s, struct sockaddr *addr, socklen_t *addrlen); addrlenの長さのアドレス(addr)でソケットsに接続することを許可する |
[ #include <sys/types.h> ] [ #include <sys/socket.> ] bind() |
int bind(int s, const struct sockaddr *name, socklen_t namelen); ソケットsに名前を割り当てる |
[ #include <sys/types.h> ] [ #include <sys/socket.h> ] connect() |
int connect(int s, const struct sockaddr *name, socklen_t namelen); ソケットsにnameで接続要求 |
[ #include <arpa/inet.h> ] htonl() |
uint32_t htonl(uint32_t hostlong); hostlong を ホストバイトオーダーからネットワークバイトオーダーに変換する |
[ #include <arpa/inet.h> ] htons() |
uint16_t htons(uint16_t hostshort); hostshort を ホストバイトオーダーからネットワークバイトオーダーに変換する |
[ #include <string.h> ] memset() |
void *memset(void *s, int c, size_t n); sが指すオブジェクトの先頭n文字に、unsigned char型に変換したcの値を代入する。 |
[ #include <stdio.h> ] fgets() |
char *fgets(char *s, int n, FILE *stream); streamからn文字取り出してsに格納する |
[ #include <string.h> ] memset() |
void *memset(void *s, int c, size_t n); sが指すオブジェクトの先頭n文字に、unsigned char型に変換したcの値を代入する。 |
[ #include <sys/types.h> ] [ #include <sys/socket.> ] socket() |
int socket(int domain, int type, int protocol); protocolを使ってtypeで指定した通信方式を使う通信範囲がdomainなソケットを作成 |
ーーーーーーーーーーーーーーーーーーーーーーー /usr/include/netinet/in.h struct sockaddr_in { __uint8_t sin_len; /* 構造体の長さ */ sa_family_t sin_family; /* アドレスファミリ(PF_INET) */ in_port_t sin_port; /* ポート番号 */ struct in_addr sin_addr; /*アドレス*/ char sin_zero[8]; /*詰物*/ }; ーーーーーーーーーーーーーーーーーーーーーーin_addr構造体の内容は
ーーーーーーーーーーーーーーーーーーーーーーー /usr/include/netinet/in.h struct in_addr { __uint32_t s_addr; /*アドレス*/ }; ーーーーーーーーーーーーーーーーーーーーーーらしい