I have an
application wherein a master controller is opening a server socket and fires off
a number of background procedures. The background procedures go about doing
their work and report status back to the master via the server socket. The
problem I am having is understanding what IP address master application open the
server socket with. As I plan to have other using this code I don't want to
hard-code the IP.
The code I use to
open the server is shown below. I am depending on the line
set addHostPort [fconfigure $channelId -sockname]
to return back the IPaddress the socket was opened with along with the port number and host name. The plan was to pass these onto the background procedures so they know how to communicate with master.
to return back the IPaddress the socket was opened with along with the port number and host name. The plan was to pass these onto the background procedures so they know how to communicate with master.
My problem is the
IPaddress returned from fconfigure is always 0.0.0.0, yet the socket opened
without error. What am I doing wrong?
Bob
##########################################################
## Procedure: serverSocket
## Procedure: serverSocket
proc {serverSocket}
{} {
global PORT
global PORT
##
# Open server socket to accept commands and call the remoteStatusRcved
# procedure when a message is received
##
# Open server socket to accept commands and call the remoteStatusRcved
# procedure when a message is received
##
postMessage "Attempting to open server socket "
set err [catch {set channelId [socket -server remoteStatusRcved $PORT]} msg]
if {$err == 0} {
set addHostPort [fconfigure $channelId -sockname]
foreach "add host port" $addHostPort" {
postMessage "Server socket opened using Address: $add Port: $port on Host: $host"
}
fconfigure $channelId -blocking 1 -translation binary -buffering line
} else {
postMessage "ERROR: Socket failed to open ($err)"
}
}
set addHostPort [fconfigure $channelId -sockname]
foreach "add host port" $addHostPort" {
postMessage "Server socket opened using Address: $add Port: $port on Host: $host"
}
fconfigure $channelId -blocking 1 -translation binary -buffering line
} else {
postMessage "ERROR: Socket failed to open ($err)"
}
}
Robert
M. Bartis
Lucent
Technologies �
Room
HO 1C-413A (HO) / 1B-304
(WH)
( 732.949.4565
(HO) / 973.386.6739 (WH)
* [EMAIL PROTECTED]
