File:  [Research Unix] / researchv10no / cmd / dist / talk / slide6
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

.BU
Tenth Edition code to make a network call:
.CO
#include <ipc.h>

\fI[...]\fP

int fd;

fd = ipcopen(ipcpath(hostname, "dk", "dist"), "heavy");
if (fd < 0) {
	fprintf(stderr, "can't call %s\\n", hostname);
	exit(1);
}
.CE
.BU
Berkeley code to make a network call:
.CO
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

\fI[...]\fP

int fd;
struct hostent *h;
struct servent *s;
struct sockaddr_in sin;

h = gethostbyname(hostname);
s = getservbyname("dist", "tcp");
fd = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = s->s_port;
memcpy(&sin.sin_addr, h->h_addr, h->h_length);
if (connect(fd, &sin, sizeof sin) < 0) {
	fprintf(stderr, "can't call %s\\n", hostname);
	exit(1);
}
.CE
.BU
Hostnames as seen from a Tenth Edition system:
.EX
dk!nj/astro/coma
tcp!pyxis.research.att.com
.EN
.BU
Hostnames as seen from a Berkeley system:
.EX
bowell.research.att.com
.EN

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.