ReactOS  0.4.14-dev-52-g6116262
UBind.c
Go to the documentation of this file.
1 #include "syshdrs.h"
2 
3 #if !defined(NO_UNIX_DOMAIN_SOCKETS)
4 
5 int
6 UBind(int sockfd, const char *const astr, const int nTries, const int reuseFlag)
7 {
8  unsigned int i;
9  int on;
10  int onsize;
11  struct sockaddr_un localAddr;
12  int ualen;
13 
14  ualen = MakeSockAddrUn(&localAddr, astr);
15  (void) unlink(localAddr.sun_path);
16 
17  if (reuseFlag != kReUseAddrNo) {
18  /* This is mostly so you can quit the server and re-run it
19  * again right away. If you don't do this, the OS may complain
20  * that the address is still in use.
21  */
22  on = 1;
23  onsize = (int) sizeof(on);
25  (char *) &on, onsize);
26  }
27 
28  for (i=1; ; i++) {
29  /* Try binding a few times, in case we get Address in Use
30  * errors.
31  */
32  if (bind(sockfd, (struct sockaddr *) &localAddr, ualen) == 0) {
33  break;
34  }
35  if (i == (unsigned int) nTries) {
36  return (-1);
37  }
38  /* Give the OS time to clean up the old socket,
39  * and then try again.
40  */
41  sleep(i * 3);
42  }
43 
44  return (0);
45 } /* UBind */
46 
47 
48 
49 
50 int
51 UListen(int sfd, int backlog)
52 {
53  return (listen(sfd, backlog));
54 } /* UListen */
55 
56 #endif
57 
#define kReUseAddrNo
Definition: sio.h:46
#define sleep
Definition: syshdrs.h:37
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define unlink
Definition: syshdrs.h:54
#define SOL_SOCKET
Definition: winsock.h:398
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
int MakeSockAddrUn(struct sockaddr_un *, const char *const)
#define SO_REUSEADDR
Definition: winsock.h:180
int UListen(int, int)
int UBind(int, const char *const, const int, const int)
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31