#include <string.h>
const char * strrchr ( const char * str, int character );
char * strrchr ( char * str, int character );
returns a pointer to the last occurrence of character in string str.
char* strstr(const char* haystack, const char* needle);
This function returns a pointer to the first occurrence in haystack of any of the entire sequence of characters specified in needle, or a null pointer if the sequence is not present in haystack.
char* index(const char* s, char c)
index()用来找出参数s 字符串中第一个出现的参数c 地址,然后将该字符出现的地址返回。字符串结束字符(NULL)也视为字符串一部分
strcat
strcpy
strlen
fdopen
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
examine and change a signal action, oldact is to save the old action of signal.
signum specifies the signal and can be any valid signal except SIGKILL and SIGSTOP
return 0 if success, return -1 if failed.
#inlcude <unistd.h>
unsigned in alarm(unsigned int seconds)
alarm() arranges for a SIGALRM signal to be delivered to the calling process in seconds seconds.
shutdown/close socket
int shutdown(int s, int how)
how = 0; 终止读取操作
how = 1; 终止写操作
how = 2; 终止读取及写操作
return 0 if success, return -1 if fail
close 关闭本进程的socket id, 便链接还是开着的,用这个socket的其他进程还能用这个链接,能读或者写这个socket id
shutdown 破坏了socket链接,
goto
in_addr_t inet_addr(const char* cp)
The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. Use of this function is problematic because -1 is a valid address (255.255.255.255). Avoid its use in favor of inet_aton(), inet_pton(3), or getaddrinfo(3) which provide a cleaner way to indicate error return.
struct sockaddr_in {
sa_family_t sin_family; /* address family: AF_INET */
in_port_t sin_port; /* port in network byte order */
struct in_addr sin_addr; /* internet address */
};
/* Internet address. */
struct in_addr {
uint32_t s_addr; /* address in network byte order */
};
void *memcpy(void *dest, const void *src, size_t n);
#include <netdb.h>
struct hostent *gethostbyname(const char *name);
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses */
}
#define h_addr h_addr_list[0] /* for backward compatibility */
#include <arpa/inet.h>
uint16_t htons(uint16_t hostshort);
The htons() function converts the unsigned short integer hostshort
from host byte order to network byte order.
#include <sys/types.h>
#include <sys/socket.h>
int connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen);