Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_unix/sys/src/cmd/unix/u9fs/remotehost.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <plan9.h>
2
#include <sys/socket.h>	/* various networking crud */
3
#include <netinet/in.h>
4
#include <netinet/tcp.h>
5
#include <netdb.h>
6
 
7
void
8
getremotehostname(char *name, int nname)
9
{
10
	struct sockaddr_in sock;
11
	struct hostent *hp;
12
	uint len;
13
	int on;
14
 
15
	strecpy(name, name+nname, "unknown");
16
	len = sizeof sock;
17
	if(getpeername(0, (struct sockaddr*)&sock, (void*)&len) < 0)
18
		return;
19
 
20
	hp = gethostbyaddr((char *)&sock.sin_addr, sizeof (struct in_addr),
21
		sock.sin_family);
22
	if(hp == 0)
23
		return;
24
 
25
	strecpy(name, name+nname, hp->h_name);
26
	on = 1;
27
	setsockopt(0, SOL_SOCKET, SO_KEEPALIVE, (char*)&on, sizeof(on));
28
#ifdef TCP_NODELAY
29
	on = 1;
30
	setsockopt(0, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on));
31
#endif
32
}