sending string thru TCP/IP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi would i like to send string of PCL codes to a Printer which i have the IP
address, how do i send it?

i'm currently using TCPclient class, but it could not work, as the printer
would just hang...

pls help me...
 
you probably have to send it as bytecode data.

I am not sure about PCL. But I had to do that for my Datamax Thermal
Printers. Convert the string to a correctly formatted bytecode array and
then send that to your printer. Usually there are control characters
involved for telling the printer to start printing and stop printing...
 
Hi,

can u elaborate more? example?

ECathell said:
you probably have to send it as bytecode data.

I am not sure about PCL. But I had to do that for my Datamax Thermal
Printers. Convert the string to a correctly formatted bytecode array and
then send that to your printer. Usually there are control characters
involved for telling the printer to start printing and stop printing...
 
Private Function PrintThisPallet(ByVal label() As Byte, ByVal netstream As
NetworkStream) As Boolean
Try
Dim startPrint(3) As Byte
startPrint = getStartPrint()
Dim endPrint(2) As Byte
endPrint = getEndPrint()

If netstream.CanRead And netstream.CanWrite Then
netstream.Write(startPrint, 0, startPrint.Length)
netstream.Write(label, 0, label.Length)
netstream.Write(endPrint, 0, endPrint.Length)
Return True

ElseIf Not netstream.CanRead Or Not netstream.CanWrite Then
Return False

End If

Public Class TCPDatagram
Private appsettings As New System.Configuration.AppSettingsReader()
Private debugLevel As Integer = appsettings.GetValue("debuglevel",
GetType(System.Int16))

Private mTcp() As TcpClient
Private mNetStream() As NetworkStream
Private mPortNumber As Integer = appsettings.GetValue("PortNumber",
GetType(System.Int32))


Public Property TcpData(ByVal i As Integer) As TcpClient
Get
Return mTcp(i)

End Get
Set(ByVal Value As TcpClient)
mTcp(i) = Value
End Set
End Property

Public Property NetStream(ByVal i As Integer) As NetworkStream
Get
Return mNetStream(i)
End Get
Set(ByVal Value As NetworkStream)
mNetStream(i) = Value
End Set
End Property

Public Sub OpenDatagram(ByVal ip As String, ByVal index As Integer)

Try
'============================
'ip = "192.168.155.99"
'============================
Dim addy As System.Net.IPAddress =
System.Net.IPAddress.Parse(ip)

TcpData(index) = New TcpClient()
TcpData(index).Connect(addy, mPortNumber)
TcpData(index).SendTimeout = 2
TcpData(index).ReceiveTimeout = 5

NetStream(index) = TcpData(index).GetStream


Catch ex As Exception
If debugLevel = 1 Then MessageBox.Show(ex.Message,
"OpenDatagram")
End Try
End Sub

Public Sub CloseDatagram(ByVal index As Integer)
Try
NetStream(index).Close()
TcpData(index).Close()
Catch ex As Exception
If debugLevel = 1 Then MessageBox.Show(ex.Message,
"CloseDatagram")
End Try
End Sub

Public Sub New(ByVal index As Integer)
ReDim mTcp(index)
ReDim mNetStream(index)

Dim counter As Integer
'For counter = 0 To index
' mTcp(counter) = New TcpClient()
'Next

End Sub

End Class 'TCPDatagram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top