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.
Send command "string" over tcp/ip
Re: Send command "string" over tcp/ip
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.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Send command "string" over tcp/ip
Can you post the VB code you are using with Wine that works please.
Re: Send command "string" over tcp/ip
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
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
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.
- Matthew-Collins
- Posts: 12
- Joined: Wednesday 21st September 2016 7:59pm
- Location: Guernsey, Channel Islands
Re: Send command "string" over tcp/ip
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
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
Cheers
Matt
Matt