#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include "sio.h"
Go to the source code of this file.
◆ main()
Definition at line 107 of file srltest.c.
108{
110
114 }
118}
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static void Server(int port)
◆ ServeOneClient()
Definition at line 23 of file srltest.c.
24{
25 char buf[80], cliAddrStr[64];
26 char bbuf[320];
29
30 printf(
"subserver[%d]: started, connected to %s.\n", (
int)
getpid(),
31 AddrToAddrStr(cliAddrStr,
sizeof(cliAddrStr), cliAddr, 1,
"<%h:%p>")
32 );
33
35 fprintf(
stderr,
"subserver[%d]: InitSReadlineInfo error: %s\n",
38 }
39 for (;;) {
41 if (nread == 0) {
42 break;
45 continue;
46 } else if (nread < 0) {
49 break;
50 }
51 for (
i=0;
i<nread;
i++)
55 if (nwrote < 0) {
58 break;
59 }
60 }
64}
int SClose(int sfd, int tlen)
GLenum GLuint GLenum GLsizei const GLchar * buf
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
int SWrite(int, const char *const, size_t, int, int)
char * AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in *const saddrp, int dns, const char *fmt)
int SReadline(SReadlineInfo *, char *const, size_t)
int InitSReadlineInfo(SReadlineInfo *, int, char *, size_t, int, int)
const char * strerror(int err)
Referenced by Server().
◆ Server()
Definition at line 69 of file srltest.c.
70{
71 int sockfd, newsockfd;
74
76 if (sockfd < 0) {
77 perror(
"Server setup failed");
79 }
80
82 for(;;) {
84 newsockfd =
SAccept(sockfd, &cliAddr, 5);
85 if (newsockfd < 0) {
88 else
91 }
else if ((
pid = fork()) < 0) {
95 }
else if (
pid == 0) {
98 } else {
99
101 }
102 }
103}
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
int SNewStreamServer(const int, const int, const int, int)
static void ServeOneClient(int sockfd, struct sockaddr_in *cliAddr)
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Referenced by _tmain(), CreateNameServerListCallback(), CreateNameServerListEnumNamesFunc(), main(), NetAddAlternateComputerName(), NetEnumerateComputerNames(), NetRemoveAlternateComputerName(), NetSetPrimaryComputerName(), ParseCommandLine(), and ScControl().