Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to use winsock to exchange data in 2 diferent exe

how to use winsock to exchange data in 2 diferent exe

Scheduled Pinned Locked Moved Visual Basic
tutorial
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zhiyuan16
    wrote on last edited by
    #1

    dear all this is first time for me to use winsock in vb6, i don't how to exchange data in 2 different exe, although i searched online, but i still didn't get what i expect. anyone can tell me this point--step by step. thanks a lot.

    L S 2 Replies Last reply
    0
    • Z zhiyuan16

      dear all this is first time for me to use winsock in vb6, i don't how to exchange data in 2 different exe, although i searched online, but i still didn't get what i expect. anyone can tell me this point--step by step. thanks a lot.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      zhiyuan16 wrote:

      this is first time for me to use winsock in vb6, i don't how to exchange data in 2 different exe,

      There's a basic example here[^]. Best way to go would be to analyze examples, and try to build something similar.

      zhiyuan16 wrote:

      although i searched online, but i still didn't get what i expect. anyone can tell me this point--step by step.

      That begs the question on what you're expecting, and what the requirements for the communications are.

      I are Troll :suss:

      1 Reply Last reply
      0
      • Z zhiyuan16

        dear all this is first time for me to use winsock in vb6, i don't how to exchange data in 2 different exe, although i searched online, but i still didn't get what i expect. anyone can tell me this point--step by step. thanks a lot.

        S Offline
        S Offline
        slam Iqbal
        wrote on last edited by
        #3

        Hi, Following sample shows the use of Winsock in vb6. Just copy, paste & Test. To Test in local mode (if currently u don't have two machines connected)
        Make "yourproject.exe" & run in double instance then:
        in 1 instance click Listen(Command2) And another click Connect(Command2).
        Then Type text in Text3 and click on Send(Command3).

        'Create a new project: Add 3 TextBox, 3 CommandButton And 1 Winsock. Do not change any of them's Name.
        'Paste this whole string inside your form's code window
        Option Explicit
        'Text1= Remote IP/MachineName; for local 127.0.0.1
        'Text2= Port Number; I used 1971; you should be sure that the given port is not in use

        'Command1=Connect
        Private Sub Command1_Click()
        Winsock1.Connect Me.Text1, Me.Text2
        End Sub

        'Command2=Start Listening
        Private Sub Command2_Click()
        Winsock1.LocalPort = Me.Text2
        Winsock1.Listen
        End Sub

        'Command3=Send Text
        Private Sub Command3_Click()
        'Text3= what you want to send
        Winsock1.SendData Me.Text3.Text
        'Me.Caption is used to display status
        Me.Caption = "Local Send" & Me.Text3.Text
        End Sub

        'Received text
        Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim AD As String
        Winsock1.GetData AD
        Me.Caption = "Remote: " & AD
        End Sub

        'ConnectionRequest
        Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
        On Error Resume Next ' Just in case there's an error, continue with next command.
        Winsock1.Close ' Close any open socket (just in case).
        'Must accept the request to continue
        Winsock1.Accept requestID
        Me.Caption = "Request accepted"
        End Sub

        'Chat session closed
        Private Sub Winsock1_Close()
        Me.Caption = "Closed"
        End Sub

        'Connected
        Private Sub Winsock1_Connect()
        Me.Caption = "Chat Started at " & Time
        End Sub

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups