1
votes

I assume I don't know python. This script sends a simple string over lan to a lan address (from my pc to a python server)

-------------------------------------------------------
    import socket
#
host ="192.168.0.17"
port =49280
#
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
#
s.sendall("set MIXER:Current/InCh/Fader/On 1 0 1\n".encode())
s.recv(1500)
s.close
-----------------------------------------------

I would like to send the same string but using vb6....

--------------------------------------------
    Private Sub Command3_Click()
Winsock1.RemoteHost = "192.168.0.17"
Winsock1.RemotePort = 49280
Winsock1.Protocol = sckTCPProtocol
Winsock1.Connect
winsock1

  Dim stringa1, stringa As String
  Dim Data() As Byte
  stringa = "set MIXER:Current/InCh/Fader/On 1 0 1\n"
  Data = StrConv(stringa, vbFromUnicode)
  
    Winsock1.SendData Data

End Sub
----------------------------------------------

but unfortunately it doesn't work. With the first script, my remote python server responds correctly, with the script in vb6 the server shows no signs of life Anyone can tell me what mistake I make? thanks to all and good continuation Mario

1
VB6 isn't a scripting language. If you want to send ANSI characters you can skip the Byte array and explicit conversion, Just send the String data. You have no code to await and accept returned response data. And what is the Variant stringa1 for anyway? But your core problem may be silly use of C syntax to try to escape a linefeed character.Bob77
Hi Bob, "string1" is just a variable that was included in the original script and had other purposes not related to sending the data. It remained written but is not needed for this purpose. I had already tried to send the string first, simply, but it didn't work...iz1kbp
If the answer below resolved your issue, kindly accept it - see What should I do when someone answers my question?desertnaut

1 Answers

1
votes

Based upon this table:

https://www.quackit.com/python/reference/python_3_escape_sequences.cfm

a \n in Python is a line feed. So in VB6 that would be vbLf.

So try changing your line to this:

stringa = "set MIXER:Current/InCh/Fader/On 1 0 1" & vbLf