Page tree
Skip to end of metadata
Go to start of metadata

UDP读写数据接口:

#include <sys/types.h>
#include <sys/socket.h>
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);


UDP应用服务端基本模型

int main(int argc, char* argv[])
{
	socket();
	bind();
	while(1){
		recvfrom();
		process_func();
		sendto();
	}
}
  • No labels