ReactOS 0.4.15-dev-7994-gb388cb6
SNew.c
Go to the documentation of this file.
1#include "syshdrs.h"
2
3int
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
18int
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
33int
34SNewStreamServer(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
63int
64SNewDatagramServer(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
int SBind(int sockfd, const int port, const int nTries, const int reuseFlag)
Definition: SBind.c:4
int SNewDatagramClient(void)
Definition: SNew.c:19
int SNewDatagramServer(const int port, const int nTries, const int reuseFlag)
Definition: SNew.c:64
int SNewStreamClient(void)
Definition: SNew.c:4
int SNewStreamServer(const int port, const int nTries, const int reuseFlag, int listenQueueSize)
Definition: SNew.c:34
USHORT port
Definition: uri.c:228
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
#define kSBindFailed
Definition: sio.h:65
#define kSNewFailed
Definition: sio.h:64
#define kSListenFailed
Definition: sio.h:66
#define closesocket
Definition: ncftp.h:477
#define errno
Definition: errno.h:18
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define SOCK_DGRAM
Definition: winsock.h:336