Results 1 to 10 of 10

Thread: Listen...

  1. #1

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    Can someone enlighten me on how, when using the winsock api, you are notified when you have incoming data (i.e. when you're listening) ?



    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  2. #2

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362

    umm...

    Ok, maybe i wasn't specific enough. I want to know how, when you using the Winsock API Listen method, how the data arrival/ connection requested events (etc) are reflected.


    Cheers.

    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  3. #3

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    Anyone?
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  4. #4
    Guest
    There is a Winsock API example here. It downloads a page from a HTTP server. Or in short, the Winsock API does not seem to be event driven. Rather,

    Code:
    	' Make the socket non-blocking, so calls to recv don't halt the program waiting for input.
    	retval = ioctlsocket(sock, FIONBIO, 1)
    	
    	' Read the response from the other system.  A more sophisticated program
    	' would watch to see if the connection ever times out (i.e., if the connection is
    	' lost).  For brevity, such code is omitted here.
    	Do
    		buffer = Space(4096)
    		retval = recv(sock, ByVal buffer, Len(buffer), 0)
    		If retval <> 0 And retval <> SOCKET_ERROR Then
    			reply = reply & Left(buffer, retval)
    		End If
    		' Process background events so the program doesn't appear to freeze.
    		DoEvents
    	Loop Until retval = 0
    The above code is from the page at vbapi.com in the link above.

  5. #5

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    For a client, this is fine. I need the process for a Server. It has to listen for new connections etc. How are incoming connections/requests reflected the the server proggy?


    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  6. #6
    Guest
    If you know C literate people, you might want them to translate the listen and accept page at MSDN for you cause it sure beats me!

  7. #7
    Guest

    Question is this what you want?

    If you want to know how to use the DataArrival and ConnectionRequest events, here ya go. I didn't really understand what you were asking

    tumblingdown

    Private Sub WinSockServer_DataArrival(ByVal bytesTotal As Long)
    On Error Resume Next
    Dim cString As String

    WinSockServer.GetData cString 'Assign incoming data to cString

    'Process data in cString example
    If Left(cString, 6) = "MsgBox" Then
    MsgBox Mid(cString, 6)
    End If
    End Sub

    Private Sub WinSockServer_ConnectionRequest(ByVal requestID As Long)
    WinSockServer.Accept requestID
    End Sub

  8. #8

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    Please. Read my question. I am not using a Control. I wish to do this using the API. Let me phrase the question another way.

    How do you make an object from an external lib (in this case winsock) hook to your (vb's) Event Sink?


    td.

    (i suspect it cannot be done)
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  9. #9
    Guest

    Question maybe it can be

    Maybe you can. I havn't tried this, but it sounds logical.

    When I run around the internet, I sometimes use several IE windows to access two different accounts on the same server. This doesn't work if the server used cookies to transfer information, but it does in other cases.

    How can I do that? The server is seeing my ip address and two different port numbers. That is how I suspect it tells the difference. If I'm right you could therefore use the API to listen and send messages on the same port and you would be fine. If you listen on port 12345, you have to send data on port 12345.

  10. #10

    Thread Starter
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    Pardon? Sorry, i don't see the relevance to the question.


    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

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