MCPcopy Create free account
hub / github.com/antirez/smallchat / initChat

Function initChat

smallchat-server.c:116–130  ·  view source on GitHub ↗

Allocate and init the global stuff. */

Source from the content-addressed store, hash-verified

114
115/* Allocate and init the global stuff. */
116void initChat(void) {
117 Chat = chatMalloc(sizeof(*Chat));
118 memset(Chat,0,sizeof(*Chat));
119 /* No clients at startup, of course. */
120 Chat->maxclient = -1;
121 Chat->numclients = 0;
122
123 /* Create our listening socket, bound to the given port. This
124 * is where our clients will connect. */
125 Chat->serversock = createTCPServer(SERVER_PORT);
126 if (Chat->serversock == -1) {
127 perror("Creating listening socket");
128 exit(1);
129 }
130}
131
132/* Send the specified string to all connected clients but the one
133 * having as socket descriptor 'excluded'. If you want to send something

Callers 1

mainFunction · 0.85

Calls 2

chatMallocFunction · 0.85
createTCPServerFunction · 0.85

Tested by

no test coverage detected