prngd는 네트워크 연결을 통해 "/ dev/random"및 "/ dev/urandom"을 시뮬레이트합니다. 유닉스 스트림 기반 도메인 소켓 ("/ var/run/egd-pool") 또는 TCP 포트 708 또는 4840 (기본값은 변경 가능)을 사용하는 IP를 지원합니다. (주 임의의 데이터를 얻기 위해이 파일 기술자를 돌려 읽으 전달할 수있는 것이다
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int devrandom(void)
{
union
{
struct sockaddr sa;
struct sockaddr_un path;
} location;
int sock;
memset(&location,0,sizeof(location));
location.path.sun_family = AF_UNIX;
strcpy(location.path.sun_path,"/var/run/egd-pool");
sock = socket(AF_UNIX,SOCK_STREAM,0);
if (sock < 0)
return -1;
if (connect(sock,&location.sa,sizeof(struct sockaddr_un)) < 0)
return -1;
return sock;
}
() :
그래서, 유닉스 도메인 소켓을 사용하여, 그것과 같을 것이 코드가 테스트되지 않음). TCP/IP 기반 연결은 소켓을 로컬 주소에 바인딩하고 원격 주소에 연결해야한다는 점에서 조금 더 복잡하지만이 유형의 코드에 대해서는 인터넷에 많은 예제가 있습니다.