Windows service problem
Hi All,
I wrote a server program using tcp sockets.my server listens on a particular IP address and port number when it comes up.
I made this program as a windows service ,which starts automatically when ever windows bootsup.
During start up my program gets all the IP addresses on that machine and opens socket(particular port say 7000) on all the IPs.
suppose the machine has 2 IPs,then there will be 2 socket opened.
ex:
tcp 10.78.118.90:7000 LISTEN
tcp 10.78.118.91:7000 LISTEN
one day i observed a strange problem,my server is listening on a junk IP which is not on that machine.
i analysed the problem and guessed it may be due to the follwoing reason.
may be my service started before DHCP client gets IP address from DHCP server.i came to know that each ethernet interface holds a junk IP address before it gets actual IP address from DHCP server.thats how i concluded that my service started listening on junk IP address.
this is my analysis,i dont know i am right or wrong.
I want to know wheather all user services(services registered by users like my program) comes up after windows services comes up or there is no dependency betwen services.
if i make my service dependent on DHCP client service,can it resolve this problem?
i dont know how to resolve this problem pls help me .
Any help is appriciated...
Thanks in Advance.
Suresh B
# 2 Re: Windows service problem
Hi All,
I wrote a server program using tcp sockets.my server listens on a particular IP address and port number when it comes up.
I made this program as a windows service ,which starts automatically when ever windows bootsup.
During start up my program gets all the IP addresses on that machine and opens socket(particular port say 7000) on all the IPs.
suppose the machine has 2 IPs,then there will be 2 socket opened.
ex:
tcp 10.78.118.90:7000 LISTEN
tcp 10.78.118.91:7000 LISTEN
one day i observed a strange problem,my server is listening on a junk IP which is not on that machine.
i analysed the problem and guessed it may be due to the follwoing reason.
may be my service started before DHCP client gets IP address from DHCP server.i came to know that each ethernet interface holds a junk IP address before it gets actual IP address from DHCP server.thats how i concluded that my service started listening on junk IP address.
this is my analysis,i dont know i am right or wrong.
I want to know wheather all user services(services registered by users like my program) comes up after windows services comes up or there is no dependency betwen services.
if i make my service dependent on DHCP client service,can it resolve this problem?
i dont know how to resolve this problem pls help me .
Any help is appriciated...
Thanks in Advance.
Suresh B
I have seen a DNS related problem because my service started before DHCP and DNS Client, by making DHCP dependancy of your service can certainly solve it, ofcourse you should confirm whether this is exactly reproducible this way or not.
# 6 Re: Windows service problem
Hi Krishna,
Thanks ...i need some clarification regarding this..if i make my service dependent on DHCP client service, Does it gurantee that my service will come up only after DHCP client comes up and finishes its work (obtained IP address from SHCP server)? or only it guarantees DHCP client comes up but it may not finshed its work.
AFIK, there is no guarantee that DHCP has finished with what your services needs, but generally it is guaranted that your service will not start before DHCP has finished initialization and started running.
I think getting notifications for address change is best way, as described by peter (wildfrog) earlier.