Fossil

Diff
Login

Differences From Artifact [c6afa8f76b]:

To Artifact [b85fb3a4bb]:


132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
132
133
134
135
136
137
138

139
140
141
142
143
144
145
146







-
+







  free(p);
}

/*
** Start a listening socket and process incoming HTTP requests on
** that socket.
*/
void win32_http_server(int iPort){
void win32_http_server(int iPort, char *zBrowser){
  WSADATA wd;
  SOCKET s;
  SOCKADDR_IN addr;
  int idCnt = 0;

  if( WSAStartup(MAKEWORD(1,1), &wd) ){
    fossil_fatal("unable to initialize winsock");
157
158
159
160
161
162
163






164
165
166
167
168
169
170
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176







+
+
+
+
+
+







    closesocket(s);
    fossil_fatal("unable to bind");
  }
  if( listen(s, SOMAXCONN)==SOCKET_ERROR ){
    closesocket(s);
    fossil_fatal("unable to listen");
  }
  printf("Listening for HTTP requests on TCP port %d\n", iPort);
  if( zBrowser ){
    printf("Launch webbrowser: %s\n", zBrowser);
    system(zBrowser);
  }
  printf("Type Ctrl-C to stop the HTTP server\n");
  for(;;){
    SOCKET client;
    SOCKADDR_IN client_addr;
    HttpRequest *p;
    int len = sizeof(client_addr);

    client = accept(s, (struct sockaddr*)&client_addr, &len);