I ran into a similar problem with some code I recieved which ran an a FP. What was happening was that the connection would be opened, the listen would return no error, but the read and write would not work. Since the code was quite complex, I had a hard time in figuring out whether this was a problem of the code or of the FP. I tried several things, which helped somewhat. For example, I told the FP that if it tried to connect and recieved no data several times in a row, it should wait before trying to reestablish communication. That seemed to help for some of the cases, but not all of them. Eventually, since this was acceptable for that system, I just had the PC reset the FP whenever it tried to open a connection for too long.
Another thing I can suggest, which works nicely for me, is to not close the connection immediately, but to let the VIs error several times in a row before closing it. Also, I'm not sure if this is necessary, but I would place the close connection outside the case and let it close even when the opening failed.
___________________
Try to take over the world!