Hi All,
I am getting an issue when I am trying to connect to 2 different IP / Port / Sockets.
To give a small idea of the background, I am trying to read two different reader heads for scales on two different IP/Port locations, from a single machine.
The system is setting up the 2nd connection correctly (and the Tsocket:New() seems to connect, but I get the following error (in the DEBUG log) when attempting the :SendData
13/01/2015 10:50:01: Connect Socket handle: 624
13/01/2015 10:50:01: Write Socket handle: 624
13/01/2015 10:50:21: Read Socket handle: 624
13/01/2015 10:50:21: 0104028001000000.kg 9900177
13/01/2015 10:50:33: Connect Socket handle: 896
13/01/2015 10:52:09: Sent: -1 Len: 10 Buffer Len: 0 Error: 10057
13/01/2015 10:52:09: Sent: -1 Len: 10 Buffer Len: 0 Error: 10057
13/01/2015 10:52:09: Sent: -1 Len: 10 Buffer Len: 0 Error: 10057
13/01/2015 10:52:09: Sent: -1 Len: 10 Buffer Len: 0 Error: 10057
......... Ad-infinitum
Effectively the code is the following for the Two Bridges (oSocketArray is an array for the two bridges)
IF EMPTY(oSocketArray[nBridge])
mUniWinConnected := .F.
mUniWinClosed := .F.
mUniWinInput := ""
oSocketArray[nBridge] := TSocket():New(UniPort)
mTimer := 0
UniWinSocket := oSocketArray[nBridge]:nSocket
oSocketArray[nBridge]:bRead = { | oSocket | mUniWinInput := oSocket:GetData() }
// Never use a MsgInfo() here because it hangs Windows!!!
oSocketArray[nBridge]:bConnect = { || mUniWinConnected := .T. }
oSocketArray[nBridge]:bClose = { || mUniWinClosed := .T. }
oSocketArray[nBridge]:lDebug = .T.
oSocketArray[nBridge]:cLogFile = "iplogfile.log"
oSocketArray[nBridge]:Connect( ALLTRIM(cIpAddr) ) // use the server IP address here
mUniIp := ALLTRIM(cIpAddr)
ENDIF
RetCode := oSocketArray[pBNumber]:SendData( str_send )
RetCodeData := oSocketArray[pBNumber]:GetData()
The system never gets beyond the SendData command and at this point, the .exe remains in memory and running the command ad-infinitum
13/01/2015 10:52:09: Sent: -1 Len: 10 Buffer Len: 0 Error: 10057
I never do a :Close() or :End() on the initial socket, but when I did try this, it still failed with the same error
Any help would be greatly appreciated.
Paul Rogers