Results 1 to 4 of 4

Thread: DDE or Winsock to Communicate

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Temecula
    Posts
    36
    I am creating an application with 2 (or 3) seperate compiled executables. How can I allow my applications to send data back and forth? (Strings, Integers - nothing much)
    I was thinking about using Winsock and using a port for my program, but this will probably be inefective.
    How could I implement DDE so that one program can send a request to another, and the other can send a reply?

    What is the easiest method, and can anyone show me some example code.

    -Chris
    (using VB6 Service Pack 4)

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Arrow

    For all communication stuffs, use the Winsock control. Here 's sample i've already gave in precedent posts.
    Code:
    'Client
    
    
    Private Sub DeconnectCommand_Click()
        tcpClient.Close
    End Sub
    
    Private Sub ConnectCommand_Click()
        On Error GoTo CheckError
        
        tcpClient.RemoteHost = PostText                  ' "XXX.XXX.XXX.XXX"
        tcpClient.RemotePort = 1001
    
        If tcpClient.State = sckConnecting Then
            ErrorText.Text = "Connecting..."
        Else: tcpClient.Connect
        End If
        Exit Sub
    CheckError:
        Call ProcessError
    End Sub
    
    Private Sub ProcessError()
        If Err.Number = 40020 Then
            ErrorText.Text = "Connection already established"
        ElseIf Err.Number = 40006 Then
            ErrorText.Text = "No answer"
        Else: MsgBox "Err n°:" & Err.Number & Chr(13) & Err.Description
        End If
    End Sub
    
    Private Sub Form_Terminate()
        tcpClient.Close
    End Sub
    
    Private Sub SendData(Message As String)
        On Error GoTo CheckError
        tcpClient.SendData Message
        Exit Sub
    CheckError:
        Call ProcessError
    End Sub
    
    Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
        tcpClient.GetData StrData
    End Sub
    
    
    'Server
    
    
    Private NumCanal As Integer
    
    Option Explicit
    
    Private Sub Form_Load()
        NumCanal = 0
        tcpServer(0).LocalPort = 1001
        tcpServer(0).Listen
    End Sub
    
    Private Sub tcpServer_ConnectionRequest(index As Integer, ByVal requestID As Long)
        If index = 0 Then
            NumCanal = NumCanal + 1
            Load tcpServer(NumCanal)
            tcpServer(NumCanal).LocalPort = 0
            tcpServer(NumCanal).Accept requestID
        End If
    End Sub
    
    Private Sub tcpServer_DataArrival(index As Integer, ByVal bytesTotal As Long)
        Dim StrData As String
        
        tcpServer(index).GetData StrData    
    End Sub
    Hope this'll help you.
    Hi-Tech Engineer

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Temecula
    Posts
    36
    Thanks! This will really help later on in my app - but it seems long winded for what I need to do..
    My program will have 2 exes - both programs will be running on the same computer, can I use any other way to transmit data between them? (Simple boolean query "is user logged on?" server reply: "true")

  4. #4
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Red face

    OK, if you're EXEs are on the same computer, that's different.

    I don't think there's a possibiliy to create a channel between two processes. (if there's one, i don't know it)

    But, you can just create a temporary file which contain what you want to exchange : this will be simpler that with Winsock.

    That's only what i can for you at the moment.
    Hi-Tech Engineer

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