Results 1 to 3 of 3

Thread: My server with a socket doesn't work

  1. #1
    evileconomist
    Guest

    Angry My server with a socket doesn't work

    I'v made a server component, (ActiveX exe) with 2 sub's and a few event handlers. The Idea is to let a client exe use the server component to connect to a VMS server.

    The following should happen:

    1) In client.exe: a user presses the connect button
    2) In server.exe: "Connect" method gets called.
    3) The "Connect" method initialized the socket control
    with a hostname and a port number. Once this completes
    a "connect" event should occur.
    4) In server.exe: The "connect" event is handled and a
    logon string is sent to the socket control which inturn passes
    it on to the VMS server.
    5) In server.exe: DataArrival events can occur...

    However, none of the events work in my App!!! Steps 1 and 2 complete, meaning that the socket was initialized and connected to the VMS server but the "connect" event never fired. Why???

    Here's the code:

    Server code: A standard ActiveX exe with Single use instancing.

    The class module code
    ============================================
    Option Explicit

    Public Sub ConnectToVMS()
    Load Form1
    Form1.Winsock1.RemoteHost = "SomeServer"
    Form1.Winsock1.RemotePort = 6666
    Form1.Winsock1.Connect
    End Sub

    Private Sub Winsock1_Connect()
    Dim strLogin As String
    strLogin = "logon string"
    Form1.Winsock1.SendData strLogin
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    Form1.Winsock1.GetData data, vbString
    End Sub

    Public Sub CloseServer()
    Form1.Winsock1.Close
    End Sub

    ============================================
    Form1 code, lies in same project as the server class module

    Private Sub Winsock1_Connect()
    Dim strLogin As String
    strLogin = "logon string"
    Winsock1.SendData strLogin
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    Winsock1.GetData data, vbString
    End Sub


    I've added the event handlers to both the module and the form, neither gets fired (ok I'm desperate!)

    What am I missing?

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Ok, for the server you need to do this:

    in the form's load function put:
    winsock1.listen

    in the coonectionrequest function put:
    winsock1.close
    winsock.accept requestid

    by doing this your server will listen for the connection and then accept it, thus connecting both computers

    Ah hah, that should do

  3. #3
    evileconomist
    Guest
    Thanks, the app is running!

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