Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "headers.h"
2
 
3
static char *hmsg = "headers";
4
 
5
int nbudphdrsize;
6
 
7
char *
8
nbudpannounce(ushort port, int *fdp)
9
{
10
	int data, ctl;
11
	char dir[64], datafile[64+6], addr[NETPATHLEN];
12
 
13
	snprint(addr, sizeof(addr), "udp!*!%d", port);
14
	/* get a udp port */
15
	ctl = announce(addr, dir);
16
	if(ctl < 0)
17
		return "can't announce on port";
18
	snprint(datafile, sizeof(datafile), "%s/data", dir);
19
 
20
	/* turn on header style interface */
21
	nbudphdrsize = Udphdrsize;
22
	if (write(ctl, hmsg, strlen(hmsg)) != strlen(hmsg))
23
		return "failed to turn on headers";
24
	data = open(datafile, ORDWR);
25
	if (data < 0) {
26
		close(ctl);
27
		return "failed to open data file";
28
	}
29
	close(ctl);
30
	*fdp = data;
31
	return nil;
32
}