use ISocket to write and then read | developer.brewmp.com use ISocket to write and then read | developer.brewmp.com

Developer

use ISocket to write and then read

Forums:

I am using ISocket to communicate with a server. what I want to do is send a command triggered by a key press, send the corresponding command string to the server, which sends back a response string. I am using the same connection to do both.

In my connectCB function, I simply make a call to writeCB, followed by a readCB, on the same connection. I do a clean up following write but not read. this does not work. the server gets stuck on reading the command string unless it gets the clean up signal. another word, if I only send the write socekt followed by the clean up, then server gets the right command string. but, then the server can not write response back, because the device already cleaned up and released the connection.

should you be able to do this write/read on the same connection? or do I have to reconnect?

Thanks

bhomass wrote:I am using ISocket to communicate with a server. what I want to do is send a command triggered by a key press, send the corresponding command string to the server, which sends back a response string. I am using the same connection to do both.
In my connectCB function, I simply make a call to writeCB, followed by a readCB, on the same connection. I do a clean up following write but not read. this does not work. the server gets stuck on reading the command string unless it gets the clean up signal. another word, if I only send the write socekt followed by the clean up, then server gets the right command string. but, then the server can not write response back, because the device already cleaned up and released the connection.
should you be able to do this write/read on the same connection? or do I have to reconnect?
Thanks
Writing followed by reading works fine on an open connection.
You need to clarify what you mean by 'clean up'.

bhomass wrote:I am using ISocket to communicate with a server. what I want to do is send a command triggered by a key press, send the corresponding command string to the server, which sends back a response string. I am using the same connection to do both.
In my connectCB function, I simply make a call to writeCB, followed by a readCB, on the same connection. I do a clean up following write but not read. this does not work. the server gets stuck on reading the command string unless it gets the clean up signal. another word, if I only send the write socekt followed by the clean up, then server gets the right command string. but, then the server can not write response back, because the device already cleaned up and released the connection.
should you be able to do this write/read on the same connection? or do I have to reconnect?
Thanks
Writing followed by reading works fine on an open connection.
You need to clarify what you mean by 'clean up'.

Also note that once you close the connection, it is not recommended that you the same ISocket object to bring up another connection. In this case, create a new one in order to connect again.

Also note that once you close the connection, it is not recommended that you the same ISocket object to bring up another connection. In this case, create a new one in order to connect again.