Find the answer to your Linux question:
Results 1 to 3 of 3
I create two script file name for "a.py" and "b.py", It's through socket connection. a.py's file writeing "os.pub(s.fileno,x)"create the file descriptor,but i don't know how to get the descriptor file ...
  1. #1
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23

    Pyhon how to get the file descriptor.

    I create two script file name for "a.py" and "b.py", It's through socket connection.
    a.py's file writeing "os.pub(s.fileno,x)"create the file descriptor,but i don't know how to get the descriptor file with "b.py"

  2. #2
    Linux Newbie
    Join Date
    Nov 2008
    Location
    Tokyo, Japan
    Posts
    243
    Do you mean to say, you want "a.py" and "b.py" to communicate through a socket? And what you are asking is, how do you inform "b.py" of the location of the socket so you can open a file descriptor? Am I correct in understanding your question?

    Usually, when two programs communicate, each program is designed to communicate at a pre-determined location, whether it is stdin->stdout using ordinary system pipes, or a "fifo" created at a particular location in the filesystem.

    This is also true for sockets: both programs must know the correct socket before they begin communicating. This can be set with an environment variable, like this:
    Code:
    export A_B_SOCKET="localhost:12345"
    Then each python program will parse this environment variable to extract the "localhost" as the host, and "12345" as the port.

    Another possibility is to define the communication host and port number in a configuration file, for example, "/etc/a_and_b.config". Then when each client program runs ("a.py" and "b.py"), they must first check the contents of this file, then open their socket connections.

  3. #3
    Just Joined! ibelieveme's Avatar
    Join Date
    Apr 2011
    Posts
    23
    Thank you man ,get to me thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...