Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Asynchronous socket problems in windows service

Asynchronous socket problems in windows service

Scheduled Pinned Locked Moved C#
helpquestioncsharpdatabasecom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    daniilzol
    wrote on last edited by
    #1

    Hi, We've wrote an app that utilizes asynchronous sockets to collect real-time information and write it into the database. We are using a slightly modified version of this example: http://www.codeproject.com/csharp/socketsincs.asp for our socket component. Our app works fine, we've been testing it for a week and a half now and it performs almost flawlessly. The problem is that we also need a windows service version of the app, we've completed the windows service a week ago but for some reason it won't work. I've tracked it down and it turns out the BeginConnect call does not work. It just won't connect to the server and therefore no socket is created. m_sock.Blocking = false; AsyncCallback _connect = new AsyncCallback(ConnectServer); m_sock.BeginConnect( epServer, _connect, m_sock ); ConnectServer should return IAsyncResult ar from which we can derive a socket, however it does not work. BeginConnect call fails and service simply fails to establish a connection. Now with the exception of couple of lines specific to the app, the code in the app and in the service is absolutely identical, yet the app works absolutely fine and the service does not. We have no idea what is wrong with the service, why it won't establish connection. We've tried running the service under the domain administrator account thinking it was security issue, but it still won't work. Anyone has any idea what's wrong here? I'm at a complete loss, been searching google for several days now to no avail.

    R 1 Reply Last reply
    0
    • D daniilzol

      Hi, We've wrote an app that utilizes asynchronous sockets to collect real-time information and write it into the database. We are using a slightly modified version of this example: http://www.codeproject.com/csharp/socketsincs.asp for our socket component. Our app works fine, we've been testing it for a week and a half now and it performs almost flawlessly. The problem is that we also need a windows service version of the app, we've completed the windows service a week ago but for some reason it won't work. I've tracked it down and it turns out the BeginConnect call does not work. It just won't connect to the server and therefore no socket is created. m_sock.Blocking = false; AsyncCallback _connect = new AsyncCallback(ConnectServer); m_sock.BeginConnect( epServer, _connect, m_sock ); ConnectServer should return IAsyncResult ar from which we can derive a socket, however it does not work. BeginConnect call fails and service simply fails to establish a connection. Now with the exception of couple of lines specific to the app, the code in the app and in the service is absolutely identical, yet the app works absolutely fine and the service does not. We have no idea what is wrong with the service, why it won't establish connection. We've tried running the service under the domain administrator account thinking it was security issue, but it still won't work. Anyone has any idea what's wrong here? I'm at a complete loss, been searching google for several days now to no avail.

      R Offline
      R Offline
      Roman Rodov
      wrote on last edited by
      #2

      LOCAL SERVICE user account, which is the default for services, does not allow network access. Set your service to run under the NETWORK SERVICE account or ADMINISTRATOR.

      D 1 Reply Last reply
      0
      • R Roman Rodov

        LOCAL SERVICE user account, which is the default for services, does not allow network access. Set your service to run under the NETWORK SERVICE account or ADMINISTRATOR.

        D Offline
        D Offline
        daniilzol
        wrote on last edited by
        #3

        We have already tried network service and domain administrator accounts. We just tried administrator and it still won't work...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups