Results 1 to 5 of 5

Thread: COM and TCP

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    26

    COM and TCP

    Can anyone help me get started with a few lines of code that will help my app catch data inbound tcp data and route to an outbound com port?

    I want the app to catch a "1" via tcp which the app will identify and send a corresponding string to a specified com port.

    I think i've got the com portion down. I just need to know how to integrate the TCP portion. any pointers are appreciated.

    Thanks
    CM

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: COM and TCP

    "COM" here means "Component Object Model" and not anything to do with serial ports.

    Sorry.

  3. #3
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Location
    Planet Earth
    Posts
    394

    Re: COM and TCP

    Is this .net, vb6, etc?
    Have you looked at the Winsock Control?
    Truly, you have a dizzying intellect.

  4. #4
    New Member
    Join Date
    Oct 2006
    Location
    Pakistan
    Posts
    2

    Re: COM and TCP

    Use the Winsock control of vb. you can use it for both on server/client to send and receive data through ports.......
    example: Private Sub Form_Load()
    Winsock1.LocalPort = 1001
    Winsock1.Listen
    End Sub

  5. #5
    Member
    Join Date
    Oct 2006
    Location
    Noida,India
    Posts
    49

    Re: COM and TCP

    Server Code :
    Option Explicit
    Private Sub Form_Load()
    With Winsock1
    .Protocol = sckTCPProtocol
    .LocalPort = 2001
    .Listen
    End With
    End Sub


    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Winsock1.Close
    Winsock1.Accept requestID
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim pData As String
    Call Winsock1.GetData(pData, vbString, bytesTotal)
    Debug.Print pData
    End Sub


    Client Code :

    Option Explicit

    Private Sub cmdConnect_Click()
    With Winsock2
    .Protocol = sckTCPProtocol
    .LocalPort = 0
    .RemotePort = 2001
    .RemoteHost = "localhost"
    .Connect
    End With
    End Sub

    Private Sub cmdSendData_Click()
    Winsock2.SendData "Hi"
    End Sub
    Rajneesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width