sending string thru TCP/IP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • notregister

    sending string thru TCP/IP

    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...
  • ECathell

    #2
    Re: sending string thru TCP/IP

    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
    "notregiste r" <notregister@di scussions.micro soft.com> wrote in message
    news:87B80034-C10F-4BA6-B433-6CDDC33407C1@mi crosoft.com...[color=blue]
    > 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...[/color]


    Comment

    • notregister

      #3
      Re: sending string thru TCP/IP

      Hi,

      can u elaborate more? example?

      "ECathell" wrote:
      [color=blue]
      > 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
      > "notregiste r" <notregister@di scussions.micro soft.com> wrote in message
      > news:87B80034-C10F-4BA6-B433-6CDDC33407C1@mi crosoft.com...[color=green]
      > > 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...[/color]
      >
      >
      >[/color]

      Comment

      • ECathell

        #4
        Re: sending string thru TCP/IP

        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.CanRe ad And netstream.CanWr ite Then
        netstream.Write (startPrint, 0, startPrint.Leng th)
        netstream.Write (label, 0, label.Length)
        netstream.Write (endPrint, 0, endPrint.Length )
        Return True

        ElseIf Not netstream.CanRe ad Or Not netstream.CanWr ite Then
        Return False

        End If

        Public Class TCPDatagram
        Private appsettings As New System.Configur ation.AppSettin gsReader()
        Private debugLevel As Integer = appsettings.Get Value("debuglev el",
        GetType(System. Int16))

        Private mTcp() As TcpClient
        Private mNetStream() As NetworkStream
        Private mPortNumber As Integer = appsettings.Get Value("PortNumb er",
        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(By Val ip As String, ByVal index As Integer)

        Try
        '============== ==============
        'ip = "192.168.155.99 "
        '============== ==============
        Dim addy As System.Net.IPAd dress =
        System.Net.IPAd dress.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,
        "OpenDatagr am")
        End Try
        End Sub

        Public Sub CloseDatagram(B yVal 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(inde x)

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

        End Sub

        End Class 'TCPDatagram


        Comment

        Working...