Home All Groups Group Topic Archive Search About

sending string thru TCP/IP

Author
7 Apr 2005 2:43 AM
notregister
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...

Author
7 Apr 2005 12:45 PM
ECathell
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...


--
--Eric Cathell, MCSA
Show quoteHide quote
"notregister" <notregis***@discussions.microsoft.com> wrote in message
news:87B80034-C10F-4BA6-B433-6CDDC33407C1@microsoft.com...
> 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...
Author
8 Apr 2005 12:33 AM
notregister
Hi,

can u elaborate more? example?

Show quoteHide quote
"ECathell" wrote:

> 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...
>
>
> --
> --Eric Cathell, MCSA
> "notregister" <notregis***@discussions.microsoft.com> wrote in message
> news:87B80034-C10F-4BA6-B433-6CDDC33407C1@microsoft.com...
> > 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...
>
>
>
Author
8 Apr 2005 12:49 PM
ECathell
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