I have noticed on my test code the “connect” side will connect, I write data to my client without issue, but then I am noticing that on my Connect side it automatically closes the connection. ( giving me a Error 102 Connection terminated message). My problem is that I haven’t called then IPCSOCKET.Close yet and I would like to keep the IPCSocket open. Any ideas? This is basic code since I am trying to understand exactly how IPC Sockets function.
Any advice is majorly appreciated.
I am using RS 2012R1 still.
Connect side:
InterAppCommunications = new IPCInterCommunication
InterAppCommunications.Path = SpecialFolder.UserHome.Child("IPC").ShellPath
InterAppCommunications.Connect
InterAppCommunications.poll
Receiving Side:
InterAppCommunications = new IPCInterCommunication
InterAppCommunications.Path = SpecialFolder.UserHome.Child("IPC").ShellPath
InterAppCommunications.Listen
do
InterAppCommunications.Poll
loop until InterAppCommunications.BufferIsEmpty
The receiving side loops back to listening. The sending side sends the socket termination. Tim my sending side codes resides in a Sub method being called from a pushbutton event. I assume that when that Sub ends that is causing the socket to terminate with a 102 even though I am not closing it?
Norman that is probably what is happening. Using a pushbutton like I am what would be a good snippet to keep this from happening? I tried some loops but failed.
In my normal app I won’t be calling any IPC connections from pushbutton events, but this is how I built my test app
If InterAppCommunications is a local variable, then that is indeed what is happening. If so, make it a property of the window so it stays alive after the button’s event.
InterAppCommunications already is a private property of the Window yes. On the Console app side it is the same but a private property of the app.
Something is funky though. I can pass data and connect using the IDE start just fine. I introduce a breakpoint on the sending side and it fails connection (103) everytime. I then remove the breakpoint and it works passing data again.
I am positive I am not diming the variable locally… Just on the property. I did remove the poll and now I step through with the debugger and it shows true for connected after the “sub end”. Weird thing is that my error log still shows a disconnect 102 from the sending side InterAppCommunications IPC Socket class. That isn’t normal is it?
// Error Check Control
If me.LastErrorCode <> 0 then
if me.LastErrorCode = 100 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " There was an error opening and initializing the drivers.")
elseif me.LastErrorCode = 102 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " Connection was terminated")
elseif me.LastErrorCode = 103 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " Unable to resolve hostname.")
elseif me.LastErrorCode = 105 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " The IP Address currently is in use.")
elseif me.LastErrorCode = 106 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " The Socket is in an invalid state.")
elseif me.LastErrorCode = 107 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " The Port number specified is invalid]")
elseif me.LastErrorCode = 108 then
mLogFacility("Tombstone IPC Code[" + str(me.LastErrorCode)+"]" + " Out of memory Error.")
else
mLogFacility("Tombstone IPC Error Code[" + str(me.LastErrorCode)+"]")
Exit
End If
end if
Tim ok. I found it. I was causing myself a nil exception error on the console app side and missed it by not checking the terminal enough You having me remove the poll from the sending side actually kept me from disconnecting. Thanks again Tim and Norman… I appreciate you taking the time with me the noobie