ReactOS  0.4.14-dev-77-gd9e7c48
SNew.c
Go to the documentation of this file.
1 #include "syshdrs.h"
2 
3 int
5 {
6  int sfd;
7 
8  sfd = socket(AF_INET, SOCK_STREAM, 0);
9  if (sfd < 0)
10  return kSNewFailed;
11 
12  return (sfd);
13 } /* SNewStreamClient */
14 
15 
16 
17 
18 int
20 {
21  int sfd;
22 
23  sfd = socket(AF_INET, SOCK_DGRAM, 0);
24  if (sfd < 0)
25  return kSNewFailed;
26 
27  return (sfd);
28 } /* SNewDatagramClient */
29 
30 
31 
32 
33 int
34 SNewStreamServer(const int port, const int nTries, const int reuseFlag, int listenQueueSize)
35 {
36  int oerrno;
37  int sfd;
38 
39  sfd = socket(AF_INET, SOCK_STREAM, 0);
40  if (sfd < 0)
41  return kSNewFailed;
42 
43  if (SBind(sfd, port, nTries, reuseFlag) < 0) {
44  oerrno = errno;
45  (void) closesocket(sfd);
46  errno = oerrno;
47  return kSBindFailed;
48  }
49 
50  if (SListen(sfd, listenQueueSize) < 0) {
51  oerrno = errno;
52  (void) closesocket(sfd);
53  errno = oerrno;
54  return kSListenFailed;
55  }
56 
57  return (sfd);
58 } /* SNewStreamServer */
59 
60 
61 
62 
63 int
64 SNewDatagramServer(const int port, const int nTries, const int reuseFlag)
65 {
66  int oerrno;
67  int sfd;
68 
69  sfd = socket(AF_INET, SOCK_DGRAM, 0);
70  if (sfd < 0)
71  return kSNewFailed;
72 
73  if (SBind(sfd, port, nTries, reuseFlag) < 0) {
74  oerrno = errno;
75  (void) closesocket(sfd);
76  errno = oerrno;
77  return kSBindFailed;
78  }
79 
80  return (sfd);
81 } /* SNewDatagramServer */
int SListen(int sfd, int backlog)
Definition: SBind.c:60
#define kSListenFailed
Definition: sio.h:66
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
int SNewDatagramServer(const int port, const int nTries, const int reuseFlag)
Definition: SNew.c:64
int errno
#define closesocket
Definition: main.c:39
int SNewStreamServer(const int port, const int nTries, const int reuseFlag, int listenQueueSize)
Definition: SNew.c:34
#define kSNewFailed
Definition: sio.h:64
#define kSBindFailed
Definition: sio.h:65
int SNewDatagramClient(void)
Definition: SNew.c:19
#define AF_INET
Definition: tcpip.h:117
int SNewStreamClient(void)
Definition: SNew.c:4
int SBind(int sockfd, const int port, const int nTries, const int reuseFlag)
Definition: SBind.c:4
#define SOCK_STREAM
Definition: tcpip.h:118
#define SOCK_DGRAM
Definition: winsock.h:336
USHORT port
Definition: uri.c:227