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 ...
- 04-19-2011 #1
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"
- 04-20-2011 #2Linux 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:Then each python program will parse this environment variable to extract the "localhost" as the host, and "12345" as the port.Code:export A_B_SOCKET="localhost:12345"
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.
- 04-22-2011 #3


Reply With Quote