textwriter.write help

Darren69

Member
Licensed User
Longtime User
Hi,

Seems another day another challenge.

I am trying to send ascii strings to a network device. All is good when I send the first command, the device receives it, but when I go to send the next command I am told the socket is not connected so I am at the moment cheating by calling a sub called connecttonuvo again to force a reconnection.

Here is my code snippit

Sub Socket1_Connected (Successful As Boolean)
If Successful = False Then

Connecttonuvo

End If


Try

tw.Initialize(Socket1.OutputStream)
tw.Write(SendString&Chr(13))

tw.close
Log("Data Sent - "&SendString)
Return

Catch
'putting this in here to suppress any errors
' nope

End Try

end sub

I put in a try and catch to stop the error about the socket not being open from being displayed.

any pointers would be great.

I have tried using tw.writeline too but its the same,

I think the tw.close is closing the socket too, is this the case? and is there another way of writing to a socket which and keeping the socket alive so the next command can be sent straight away?

the command I am sending includes CHR(13) which is how my networked device knows to action the command it has received.

thanks in advance

Darren
 

Darren69

Member
Licensed User
Longtime User
Thanks Erel,

I will try and get my head around the AsyncStreams, the example in the tutorials made my head hurt, i could not see where you tell it where to connect to, so I will do some more digging so I can understand it properly

thanks

Darren
 
Upvote 0
Top