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. Database & SysAdmin
  3. System Admin
  4. Socket Programming

Socket Programming

Scheduled Pinned Locked Moved System Admin
sysadminquestion
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.
  • C Offline
    C Offline
    cdehelean
    wrote on last edited by
    #1

    Hi Guys I have following technical question. Maybe someone has the knowhow, so I wouldn´t have to worry about seeking further I have a server, he receives as input parameter a port number. So I want to find out what process established the connection through this port. More rigurous: I would like to find a method about determining a Process ID knowing a port number of a connection opened by this process. Any hint would be highly appreciated. Thanx

    T 1 Reply Last reply
    0
    • C cdehelean

      Hi Guys I have following technical question. Maybe someone has the knowhow, so I wouldn´t have to worry about seeking further I have a server, he receives as input parameter a port number. So I want to find out what process established the connection through this port. More rigurous: I would like to find a method about determining a Process ID knowing a port number of a connection opened by this process. Any hint would be highly appreciated. Thanx

      T Offline
      T Offline
      Tim Deveaux
      wrote on last edited by
      #2

      One way to do this is to write a filter driver for the transport layer and maintain stats on sockets/processes. Sysinternals offers a utility that does this (href=http://www.sysinternals.com/ntw2k/freeware/tdimon.shtml), but no source. But for the less rigorous case, can you encode the PID into PID + large_num (where large num = say, 10000) and bind to that port number before connecting? Then the server can call getpeername and deduce the PID. Might require some massaging if one process opens more than one connection. Why needest thou this?

      C 1 Reply Last reply
      0
      • T Tim Deveaux

        One way to do this is to write a filter driver for the transport layer and maintain stats on sockets/processes. Sysinternals offers a utility that does this (href=http://www.sysinternals.com/ntw2k/freeware/tdimon.shtml), but no source. But for the less rigorous case, can you encode the PID into PID + large_num (where large num = say, 10000) and bind to that port number before connecting? Then the server can call getpeername and deduce the PID. Might require some massaging if one process opens more than one connection. Why needest thou this?

        C Offline
        C Offline
        cdehelean
        wrote on last edited by
        #3

        Thanks a lot. I will do it with your first approach. The whole thing is based on the need to make an app work in a Terminal Services environmnent. It's something strange, I got a telnet session on a foreign OS. From there I launch a command like RunWord. The process of this command retrieves through native API's the IP adress and client port number of the telnet session . These parameters are sent to a service on the Terminal Server, that now has to decide on what Session to open Word. So one approach is to search for the PID of the open port, to get from this PID the SessionID and to launch Word in this Session. All I need is a roadmap and then I might be able to find a clue.

        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