Posts

Showing posts with the label tcp

TCP Server failing after first response

TCP Server failing after first response NOTE I rewrote this question for the bounty as i was able to figure out how to get the first question solved but didn't want to start a new question. the comments below pertain to the original question, not the revised. Description of Issue My tcp client executes querying the tcp server one time successfully, returns the response, and then subsequent requests to the server from the client fails. Also, if i terminate the client and reload it fails on the first attempt as well. Here's what my command prompt looks like: root@ubuntuT:/home/jon/gocode/udps# ./udpservtcpclient Text to send: SampleQuery Message from server: SampleResponse Text to send: SampleQuery ((End - No Response)) root@ubuntuT:/home/jon/gocode/udps# ./udpservtcpclient Text to send: SampleQuery ((End - No Response)) What I expect I expect to be able to query the tcp server from the tcp client endlessly, and have the tcp server return a response from the UDP Server every tim...

How can client application find dynamically selected TCP port opened by server (Java)?

How can client application find dynamically selected TCP port opened by server (Java)? I have a windows service which opens a TCP port (one that was available at given moment). Now I need to connect a client to that port. How do I let the client know which port the server is running on? 2 Answers 2 Unless you have some way to communicate with the service from your Java program, this will not be that simple. One solution could be to try parsing the output of the netstat command. For more details on how to do that you can look at this question netstat You can't really solve this in the general case without either having the client try all the ports until it somehow recognizes the server, or communicating by some other method. The easiest solution is to agree on a file name in an agreed location (the temp directory, for example) and store the port number in that file. T...