Page 2 of 2

Re: Send command "string" over tcp/ip

Posted: Sunday 25th February 2018 10:10am
by stevedee
jornmo wrote: Sunday 25th February 2018 8:17am ...Its the javascript on this site that takes care of the syntax highlighting...
Thanks Jornmo, don't waste any time on it, I was just curious. I couldn't see any non-printing characters or anything unusual that might cause it within the text block.

Re: Send command "string" over tcp/ip

Posted: Sunday 25th February 2018 1:51pm
by agili
Cogier: I compiled the code with no errors but got time out and no reaction from print server, I started the app and started terminal , used the command : netstat -at , my specified port did not appear at all no communication. By the way if I use the app I created in windows with VB (run with wine on linux mint 18) I get response with the print server and can send commands successfully. I am stuck.

Re: Send command "string" over tcp/ip

Posted: Monday 26th February 2018 12:21pm
by cogier
Can you post the VB code you are using with Wine that works please.

Re: Send command "string" over tcp/ip

Posted: Tuesday 27th February 2018 10:05pm
by agili
Cogier: This code is writen in visual Basic 2017 on windows 10 and perfectly works:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim ipAddress As String = "192.168.100.237"
Dim port As Integer = 9100
Dim ZPLString As String =
"^XA" &
"~JA" &
"^XZ"
Try
'Open Connection
Dim client As New System.Net.Sockets.TcpClient
client.Connect(ipAddress, port)
'Write ZPL String to Connection
Dim writer As New System.IO.StreamWriter(client.GetStream())
writer.Write(ZPLString)
writer.Flush()
'Close Connection
writer.Close()
client.Close()
Catch ex As Exception
End Try

End Sub

Re: Send command "string" over tcp/ip

Posted: Wednesday 28th February 2018 8:42am
by stevedee
agili wrote: Sunday 25th February 2018 1:51pm...I started the app and started terminal , used the command : netstat -at , my specified port did not appear at all no communication...
Please put a breakpoint at the line:-
If ClientSocket.Status > Net.Inactive Then
...and then run the code in the Gambas IDE.

If the code does not stop at the breakpoint, then there is an error and you should see info in the lower window in the IDE.

If the code stops at the breakpoint, use netstat -at in a terminal and see if the port is open.

The example I gave you is very basic. In my blog post is does say that you should add error detection. Also, in my example above, the string commands may not be correct, so the socket may just be opening and then closing (as expected), so you wont see it on netstat unless you pause the code.

The command string may need to be changed (e.g. to include CR + LF). But the first step is to ensure the socket is working as expected.

EDIT: you don't need to compile the code each time, just click the Run button in the IDE to test your code.

Re: Send command "string" over tcp/ip

Posted: Thursday 1st March 2018 3:37pm
by Matthew-Collins
Hi Agili,

Myself and Charlie have done some testing for you, the issue is the iptables firewall on linux mint.

Try these steps:
1) Turn Off ufw firewall > Status: Off (can be done from gufw "Firewall Configuration")

In Terminal:
2) sudo iptables --flush
3) sudo iptables -X
4) sudo iptables --list (3 sections should be shown all saying: Accept)

5) Restart PC

For more information about the iptables and ufw firewall, see this link:
https://help.ubuntu.com/community/IptablesHowTo