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. Socket Programming

Socket Programming

Scheduled Pinned Locked Moved C#
csharpdatabasehelpannouncement
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.
  • S Offline
    S Offline
    Saamir
    wrote on last edited by
    #1

    Hi guys, I am trying to update an old application that was designed by another programmer. I am not very sharp at C# and need your help. Can you please help me understand the following code that is in the windows service IPHostEntry hostEntry=Dns.Resolve(m_sServerAddr); IPAddress ipAddress = hostEntry.AddressList[0]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,m_nPort); m_svSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); m_svSocket.Bind(ipEndPoint); m_svSocket.Listen(10); while(true) { Socket rtSocket=m_svSocket.Accept(); if(rtSocket.Connected) { TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest); TD.ThreadPool.QueueUserWorkItem(myCallBack,rtSocket); } } ProcessClientRequest has a bunch of functions called like getschedule from database etc. I am trying to force Processclientrequest to reload the schedule from the database without restarting the service. Please help.

    Sameer

    S 1 Reply Last reply
    0
    • S Saamir

      Hi guys, I am trying to update an old application that was designed by another programmer. I am not very sharp at C# and need your help. Can you please help me understand the following code that is in the windows service IPHostEntry hostEntry=Dns.Resolve(m_sServerAddr); IPAddress ipAddress = hostEntry.AddressList[0]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,m_nPort); m_svSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); m_svSocket.Bind(ipEndPoint); m_svSocket.Listen(10); while(true) { Socket rtSocket=m_svSocket.Accept(); if(rtSocket.Connected) { TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest); TD.ThreadPool.QueueUserWorkItem(myCallBack,rtSocket); } } ProcessClientRequest has a bunch of functions called like getschedule from database etc. I am trying to force Processclientrequest to reload the schedule from the database without restarting the service. Please help.

      Sameer

      S Offline
      S Offline
      Spacix One
      wrote on last edited by
      #2

      Wow, looks more like a coding horror to me... People run that code on their PC??


      -Spacix All your skynet questions[^] belong to solved

      S 1 Reply Last reply
      0
      • S Spacix One

        Wow, looks more like a coding horror to me... People run that code on their PC??


        -Spacix All your skynet questions[^] belong to solved

        S Offline
        S Offline
        Saamir
        wrote on last edited by
        #3

        no the service is installed on the server. It has run and currently runs great with no problems. What do you mean by coding horror? Also, the attached code is called by the timer. Here is the full function. private void StartTimerAndServerSocket() { Writ2ErrLog("Service Timer Initialized"); string sErr="Application is ready for processing"; try { Writ2ErrLog(sErr); m_tMonitor = new TD.Timer(new TD.TimerCallback(MonitorFunc),1, 0,45000);//45 sec if(m_sServerAddr==string.Empty) { m_sServerAddr=Dns.GetHostName(); } if(m_nPort==-1) { m_nPort=1024; } IPHostEntry hostEntry=Dns.Resolve(m_sServerAddr); IPAddress ipAddress = hostEntry.AddressList[0]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,m_nPort); m_svSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); m_svSocket.Bind(ipEndPoint); m_svSocket.Listen(10); while(true) { Socket rtSocket=m_svSocket.Accept(); if(rtSocket.Connected) { TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest); TD.ThreadPool.QueueUserWorkItem(myCallBack,rtSocket); } } } catch(Exception ex) { m_svSocket.Close(); m_tMonitor.Dispose(); sErr="Start Error " + ex.Message; } finally { if(sErr!=string.Empty) { Debug.WriteLine(sErr); Writ2ErrLog(sErr); } }

        Sameer

        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