title: windows service, can't have network access until user logon
body: <p>I am trying to write a simple window service on window 7 64bit. The user account for the service is LocalSystem. </p>
  
  <p>What I want to do is just a basic server/client socket program and the server exists in a windows service. The service just does a simple thing. When it starts, it creates a thread to listen on a port and wait for client connecting using window socket apis. <strong>But the problem is the client can't connect to the server until a user login the machine on which the service is running.</strong> </p>
  
  <p>Below is my code for installing the service.</p>
  
  <pre class="lang-c prettyprint-override"><code>wchar_t szPath[MAX_PATH];
  SC_HANDLE schSCManager = NULL;
  SC_HANDLE schService = NULL;
  
  GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath);
  schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE);
  schService = CreateService(
      schSCManager,
      L"msdcontrol",
      L"msd control",
      SERVICE_ALL_ACCESS,
      SERVICE_WIN32_OWN_PROCESS,
      SERVICE_AUTO_START,
      SERVICE_ERROR_NORMAL,
      szPath,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL
  );
  </code></pre>
  
  <p>What am i doing wrong?</p>