feafb7d6695249f086518bf24e1b6fd2881a35a8
[ghc-hetmet.git] / ghc / lib / misc / cbits / getSockName.c
1 #if 0
2 %
3 % (c) The GRASP/AQUA Project, Glasgow University, 1996
4 %
5 \subsection[getSockName.lc]{Return name of process assoc with socket}
6
7 \begin{code}
8 #endif
9
10 #define NON_POSIX_SOURCE
11 #include "rtsdefs.h"
12 #include "ghcSockets.h"
13
14 StgInt
15 getSockName(I_ sockfd, A_ peer, A_ namelen)
16 {
17     StgInt name;
18     
19     while ((name = getsockname((int) sockfd, (struct sockaddr *) peer, (int *) namelen)) < 0) {
20       if (errno != EINTR) {
21           cvtErrno();
22           stdErrno();
23           return -1;
24       }
25     }
26     return name;
27 }