|
-
Oct 5th, 2006, 07:51 PM
#1
Thread Starter
Junior Member
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
-
Oct 8th, 2006, 12:43 PM
#2
Re: COM and TCP
"COM" here means "Component Object Model" and not anything to do with serial ports.
Sorry.
-
Oct 9th, 2006, 10:43 AM
#3
Hyperactive Member
Re: COM and TCP
Is this .net, vb6, etc?
Have you looked at the Winsock Control?
Truly, you have a dizzying intellect.
-
Nov 6th, 2006, 05:39 AM
#4
New Member
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
-
Nov 7th, 2006, 01:53 AM
#5
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|