jhorwood28
jhorwood28

Reputation: 19

Client server (service) application connecting locally but not over the network

I have created a windows service server program in c# which will receive data messages from a serial port and then send those messages to any clients that have connected to the server. I have also developed the client program (windows form) in c#.

Originally the server program was developed as a console application to make development easier. While running the server as a console application the connections to the clients worked well, I could run a client on the same PC as the server and also connect a client on a laptop connected to the same network.

The connection method is: -client starts up -client broadcasts (udp) to a specific port -server responds to the UDP broadcast -client initiates a TCP connection with the server using the IP address obtained from the UDP response

Since changing the server from a console application to a windows service I can no longer connect the client program running on the laptop to the server using this method. The client program running on the same machine as the server connects successfully. Can anyone offer some advice on what to investigate?

Upvotes: 1

Views: 734

Answers (1)

jhorwood28
jhorwood28

Reputation: 19

To solve the issue I was having I added a new rule in the firewall settings of the machine running the server service application. I allowed the port used on incoming connections and this solved the problem for me.

I also changed the network discovery procedure:

  1. Server broadcasts every second to a port (UDP)
  2. Client awaits the broadcast packet from the server
  3. Client establishes a TCP connection with the server using the IP address obtained from the broadcast packet

Upvotes: 1

Related Questions